I created a field param to allow the user to select which column to display in a table with a few other columns (ID and Name).
The field param was set up like this:
Service Fields to Review = {
("Age Max", NAMEOF('Service'[ServiceCustom_AgeMax]), 0),
("Age Min", NAMEOF('Service'[ServiceCustom_AgeMin]), 1),
("Eligibility Text", NAMEOF('Service'[ServiceCustom_EligibilityText]), 2)
}
This works great! I then wanted to filter the table so that if a row has a blank value for the selected field param column that it would be filtered out (ex: If I select "Age Max" the table will show that column, and remove any rows where "Age Max" is blank).
After some googling I tried this measure:
Show Row =
VAR SelectedField = SELECTEDVALUE('Service Fields to Review'[Service Fields to Review])
VAR Result =
SWITCH(
True(),
SelectedField = "Age Max", NOT ISBLANK(SELECTEDVALUE('Service'[ServiceCustom_AgeMax])),
SelectedField = "Age Min", NOT ISBLANK ( SELECTEDVALUE ( 'Service'[ServiceCustom_AgeMin] ) ),
SelectedField = "Eligibility Text", NOT ISBLANK ( SELECTEDVALUE ( 'Service'[ServiceCustom_EligibilityText] ) ),
TRUE(), TRUE() -- default: show row
)
RETURN Result
Trying to use this field though throws the following error: Calculation error in measure 'Service Fields to Review'[Show Row]: Column [Service Fields to Review] is part of composite key, but not all columns of the composite key are included in the expression or its dependent expression.
I then followed the advice in this link: Using SELECTEDVALUE with Fields Parameters in Power BI - SQLBI, and changed my meausre to this:
Show Row Foo =
VAR SelectedField = SELECTCOLUMNS(SUMMARIZE('Service Fields to Review', 'Service Fields to Review'[Service Fields to Review], 'Service Fields to Review'[Service Fields to Review Fields]), 'Service Fields to Review'[Service Fields to Review])
VAR Result =
SWITCH(
True(),
SelectedField = "Age Max", NOT ISBLANK(SELECTEDVALUE('Service'[ServiceCustom_AgeMax])),
SelectedField = "Age Min", NOT ISBLANK ( SELECTEDVALUE ( 'Service'[ServiceCustom_AgeMin] ) ),
SelectedField = "Eligibility Text", NOT ISBLANK ( SELECTEDVALUE ( 'Service'[ServiceCustom_EligibilityText] ) ),
TRUE() -- default: show row
)
RETURN Result
This worked in that I can add that measure to the table and see it showing True/False correctly for each row.
The problem is, if I go to the filter tab and try to set that measure to only show True values (i.e. filter out the blank rows), the measure box in the filters pane doesn't actually expand. If I click the expand button the arrow changes but nothing else appears. I don't see a basic filter to select True or False, or an advanced filter to set it to only show True. The expanded and unexpanded view look exactly the same (just displaying the measure name).
Any ideas on why the filter expansion isn't working, or other points on how I can effectively filter a table based on the selected field param?