Forum Discussion

dixanthomass's avatar
dixanthomass
Regular Visitor
2 years ago
Solved

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:

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

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    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.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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.