Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bimmylee
Frequent Visitor

List Parameter only passes Current Value

I am trying to retrieve detail records for every six-digit ID of a list. I have a parameter that is fed this list:

bimmylee_1-1675285069328.png

 

 

I want the parameter to pass the correct value when its function (API call) is invoked for each row of a table (which should be based on the matching row ID of the table) to pull those detail records:

bimmylee_2-1675285230948.png

 

However, it only ever passes the "Current Value" to every row instead of the correct value (the matching one from the CampaignID column). If I uncheck the "Required" box and leave Current Value blank, I get an error about not being able to convert null into text. How can I get around the Current Value requirement so that it dynamically picks the appropriate value based on the row and retrieves the detail records for that row? What is the correct solution here?

 

Edit: For further context, here is the function I am invoking in the custom column:

() => let
        Source = Xml.Tables(Web.Contents(https://webapi.urlexample.com/webapi/v01.0/eobjects/XMLData/ & "CampaignOpenClickDetails/" & Number.ToText(CampaignIdParameter) & "?pageon=1&pagesize=500", [Headers=[#" UserKey”=”key”,#" Company"="company", #"UserName"="user"]])),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ErrorCount", Int64.Type}, {"SuccessCount", Int64.Type}, {"TotalQueryCount", Int64.Type}}),
        ResultMessages = #"Changed Type"{0}[ResultMessages],
        Campaign = ResultMessages{0}[Campaign],
        Recipients = Campaign{0}[Recipients],
        MailingList = Recipients{0}[MailingList],
        MailingListSubscriber = MailingList{0}[MailingListSubscriber]
    in
        MailingListSubscriber
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Do you need to create a parameter for this? I'm not at my desk, but can't you just replace

 

& Number.ToText(CampaignIDParameter)

 

with

 

& each Number.ToText([CampaignID])

 

--Nate

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

@Anonymous is correct. You should pass the ID value from the row, not a single parameter value.

 

A parameter is designed to be constant throughout the query. It's not a variable that gets updated for each row.

Anonymous
Not applicable

Do you need to create a parameter for this? I'm not at my desk, but can't you just replace

 

& Number.ToText(CampaignIDParameter)

 

with

 

& each Number.ToText([CampaignID])

 

--Nate

Hello @Anonymous and @AlexisOlson ,

Thanks very much for your replies. For some reason I thought a parameter was necessary here but I'm glad to be corrected.
I tried replacing the parameter call in this function with the value ID from the row as Nate suggested but was hit with

Expression.SyntaxError: Token Literal Expected

 at the "each" keyword, so I wrapped it in parenthesis:

() => let
        Source = Xml.Tables(Web.Contents("https://webapi.urlexample.com/webapi/v01.0/eobjects/XMLData/" & "CampaignOpenClickDetails/" & (each Number.ToText([CampaignId]) & "?pageon=1....

 and was then hit with

An error occurred in the 'Campaign Data function' query. Expression.Error: We cannot apply operator & to types Text and Function.
Details:
Operator-&
Left=https://webapi.urlexample.com/webapi/v0.1.0/eobjects/XMLData/CampaignOpenClickDetails/
Right=[Function]

 I'm sure there is some silly syntactical mistake I'm overlooking here but I'm not well-versed enough in M to recognize it.

I figured it out. I was trying to add & each Number.ToText([CampaignID]) to the function when really I needed to scrap the function altogether and just put it into the custom column query itself. Also, Power BI didn't like me using Number.ToText but when I changed the CampaignID column data type to Text pre-emptively and THEN referenced those values in the custom column, it worked. Thank you @Anonymous and @AlexisOlson for sending me down the right path!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors