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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dixanthomass
New Member

Get slicer value in M query as a comma separated string

I have a slicer, and I want to get the multiple values selected in the slicer in the M query, to call an API with a filter as per the selected values.
For testing purposes, I'm using sample data to load the slicer and using a measure to append the selected values into a string as below:

Screenshot 2024-04-23 154215.png

I want to get the selected values in my M query, from where I'm calling the API.

 

 

let
// Define the base URL of the API
baseURL = "https://api.example.com/data",

// Define the OData filter
odataFilter = "?$filter=Name in ('John','Sam')",

// Construct the full URL with the OData filter
fullURL = baseURL & odataFilter,

// Call the API
apiResponse = Web.Contents(fullURL),

// Convert the response to JSON
jsonResponse = Json.Document(apiResponse),

// Convert the JSON response to a table (if applicable)
// Replace "Record.FieldValues" with the appropriate function to extract data from your JSON response
dataTable = Table.FromRecords({Record.FieldValues(jsonResponse)})
in
dataTable

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

2 REPLIES 2
v-kaiyue-msft
Community Support
Community Support

Hi @dixanthomass ,

 

Can I ask if your problem has been resolved? If it has been resolved, could you please mark useful replies as ‘Answered’? This will help others in the community to easily find a solution if they are experiencing the same problem as you. Thanks.

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@dixanthomass , I doubt you can get the selected value in M, unless we use the dynamic M parameter

 

https://blog.crossjoin.co.uk/2020/10/25/why-im-excited-about-dynamic-m-parameters-in-power-bi/

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.