none
Invoke a step in query based on condition RRS feed

  • Question

  • Hi All,

    I have a requirement, wherein the invocation of REST API is required to be restricted .

    I was wondering, how can I use the IF condition provided by M Language.

    Sample Code :

    let
        Source = Json.Document(Web.Contents("http://jenkins.com:8080/api/json?tree=jobs[name,url]")),
        jobs = Source[jobs],
        #"Converted to Table" = Table.FromList(jobs, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"name", "url"}, {"Column1.name", "Column1.url"}),
        #"Renamed Columns" = Table.RenameColumns(#"Expanded Column1",{{"Column1.name", "JobName"}, {"Column1.url", "JobUrl"}}),

    <<If Condition based on JobName and then call the below STEP>>

        #"JobData" = Table.AddColumn(#"Renamed Columns", "Custom", each Json.Document(Web.Contents("http://jenkins.com:8080/job/"&[JobName]&"/api/json?pretty=true&depth=4&tree=builds[builtOn,result,changeSet[items[msg,author[fullName]]],duration,timestamp,id,building,actions[causes[userId]]]")))

    in
        #"Added Custom"

    Thanks in advance.

    Regards

    Milind


    Best Regards

    Thursday, October 27, 2016 4:24 PM

Answers

  • Hi milind,

    The if statement must be included within a variable, for example:

    JobData = if "JobName" = "xxxx" then
                       <doSomething>
                    else
                        <doSomethingElse>


    Thursday, October 27, 2016 5:46 PM