Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon'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.
I am trying to retrieve detail records for every six-digit ID of a list. I have a parameter that is fed this list:
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:
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
Solved! Go to Solution.
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
@watkinnc 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.
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 @watkinnc 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 @watkinnc and @AlexisOlson for sending me down the right path!