cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Microsoft
Microsoft

How to use selected slicer value as query parameter in web call

I'm a little blocked trying to figure out how to make a web service call using what the user selected in a slicer as the value of a query parameter. As a simplified example, say my web service takes a single JSON product id (pid), and returns a single JSON value (price), transforms it to a table, and shows it in the UI. I can create a query that does:

let
selected_pid_value = "a",
url = "<myurl>",
body = Json.FromValue([pid = selected_pid_value]),
Source = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = body ] )),
#"Converted to Table" = Record.ToTable(Source)
in
#"Converted to Table"

and this will work because I hard-coded the value for selected_pid_value. Now say I create a new table called "pid" using the following:

click: Enter Data
enter: a, b, c
type: Name: pid
click: Load

Create a slicer for it, and lastly create a measure for it using:

pid_value = SELECTEDVALUE(pid[Value])

Then, instead of hard-coding the value for selected_pid_value above, I use:

selected_pid_val = [pid_value],

This gives me the following error:

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to use selected slicer value as query parameter in web call

@roalexan 

 

You may take a look at the post below.

https://community.powerbi.com/t5/Desktop/How-do-I-Call-a-Power-Query-M-Function-from-a-DAX-Measure/m...

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Super User IV
Super User IV

Re: How to use selected slicer value as query parameter in web call

Today you cannot do that...

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Community Support
Community Support

Re: How to use selected slicer value as query parameter in web call

@roalexan 

 

You may take a look at the post below.

https://community.powerbi.com/t5/Desktop/How-do-I-Call-a-Power-Query-M-Function-from-a-DAX-Measure/m...

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors