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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jeremyt
Frequent Visitor

Using FIeld Params to Choose Table Column and Filter that Table Based on Selected Column

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?
1 ACCEPTED SOLUTION
nielsvdc
Impactful Individual
Impactful Individual

Hi @jeremyt, instead of returning TRUE/FALSE, you can try to return the values 1/0 and see if that works. It sometimes happens that boolean measure results are not shown as options in the filter pane.

 

Hope this helps. If so, please give kudos 👍 and mark as Accepted Solution ✔️ to help others.

View solution in original post

2 REPLIES 2
nielsvdc
Impactful Individual
Impactful Individual

Hi @jeremyt, instead of returning TRUE/FALSE, you can try to return the values 1/0 and see if that works. It sometimes happens that boolean measure results are not shown as options in the filter pane.

 

Hope this helps. If so, please give kudos 👍 and mark as Accepted Solution ✔️ to help others.

That worked perfectly! 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.