Power BI
NewCreate DAX function that will return the field selected in Field Parameter as a table expression
Ed Hansberry on 24 Jan 2023 16:38:08
When you create a Field Parameter that uses fields from (dim) tables, not measures, we need the ability to get that field as field, not just the name of the field as a string. I'll use a pseudo DAX function SELECTEDFIELDPARAMETER as a code example. SELECTEDFIELDPARAMETER would return a table expression, similar to VALUES
DISTINCTCOUNT( SELECTEDFIELDPARAMETER(Field Parameter[Field Parameter) )
This would dynamically allow me to get the number of values in the selected field even when the data is further filtered by other slicers or filters in the Filter Pane.
The only way to currently do this is to create a measure using SWITCH that gets the selected field parameter field as a string, which is a bit difficult as SELECTEDVALUE() doesn't work - instead you have to use a combination of SUMMARIZE and SELECTCOLUMNS - but that is another 'Idea', and then compare the text string against a list of items in the SWITCH function to then return the desired result.