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
asparagus1_
Helper I
Helper I

How to dynamically filter rows using a parameter table?

Hi everyone,
I'm working on a Power BI report where users can select one or more KPIs from a parameter table (e.g., KPI1, KPI2, KPI3). I want to filter out rows from my data table where all selected KPIs are equal to 0.

Here’s a simplified example of my data:

Dimension KPI1 KPI2 KPI3

A000
B1005
C001
D000

If the user selects KPI1 and KPI3, I want to exclude rows A and D, because both selected KPIs are 0 in those rows.

My current approach (pseudo-code):
I tried using a combination of SWITCH() and CONCATENATEX() to build dynamic conditions based on selected KPIs:

VAR __SelectedValue =
    SELECTCOLUMNS (
        SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
        Parameter[Parameter]
    )
RETURN CONCATENATEX ( __SelectedValue, Parameter[Parameter], ", " )

Then I use something like:

SWITCH (
    [SelectedKPIs],
    "KPI1", [KPI1],
    "KPI1,KPI2", IF([KPI1] <> 0 || [KPI2] <> 0,1,0)
    ...
) and then I apply <>0 filter based on this measure on the visualisation.

This is just pseudo-code to illustrate the logic.

The problem:
This approach doesn’t scale well when there are many KPIs and combinations. Also, SELECTEDVALUE() doesn’t work with parameter tables when multiple values are selected, so I can't easily build a dynamic condition.

Question:
Is there a better way to dynamically filter rows where all selected KPIs are equal to 0, based on a parameter table - without manually listing all combinations?

Thanks in advance for any ideas or suggestions!

1 ACCEPTED SOLUTION

Hi @asparagus1_,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @bhanu_gautam and @wardy912 for the prompt response.

 

Based on the requirement, you can still use the unpivot approach even if you only have a parameter table and no separate KPI table in your model.

In Power Query, unpivot your KPI columns so the table has the format (Dimension, KPI, Value) using the KPI names from your parameter table so that it is fully dynamic. And when you add new KPIs to the parameter table, they are automatically included without changing the DAX.

 

After unpivoting, create a measure for example like below:

ShowRow = VAR SelectedKPIs = VALUES( Parameter[KPI] )

VAR NonZeroCount =

    CALCULATE(

        COUNTROWS(YourUnpivotedTable),

        TREATAS(SelectedKPIs, YourUnpivotedTable[KPI]),

        YourUnpivotedTable[Value] <> 0

    )

RETURN IF(NonZeroCount > 0, 1, 0)

 

This measure will return 1 for any row where at least one of the selected KPIs in the parameter table has a non-zero value.

And use ShowRow = 1 as a visual level filter. This works for any KPI selection and scales to any number of KPIs without listing combinations in DAX.

 

 

Thanks and regards,

Anjan Kumar Chippa

View solution in original post

8 REPLIES 8
wardy912
Memorable Member
Memorable Member

Hi @asparagus1_ 

 

 With scalability in mind, you could consider unpivotting the table as follows:

 

Select the dimension column, then from the 'Transform' ribbon in power query, select 'Unpivot Other Columns'

The result will look like this

 

wardy912_6-1755092546975.png

 

Rename the column 'Attribute' to 'KPI', close and apply power query.

 

Add the following measure

 

ShowRow = 
VAR SelectedKPIs = VALUES(KPITable[KPI])
VAR NonZeroCount =
    CALCULATE(
        COUNTROWS(KPITable),
        KPITable[KPI] IN SelectedKPIs,
        KPITable[Value] <> 0
    )
RETURN
    IF(NonZeroCount > 0, 1, 0)

 

This will show 1 when there is a value present across the original tables rows

wardy912_7-1755092643306.png

 

Use this as a visual level filter, showrow = 1.

 

wardy912_8-1755092686183.png

 

 

This solution will be dynamic, allowing full scalability no matter how many KPIs you have!

 

I hope this helps, please give a thumbs up and mark as solved if it does, thanks!

 

 

 

Thank you for your help! Unfortunately, this solution won’t work because I don’t have a KPI table, I have parameters table.

bhanu_gautam
Super User
Super User

@asparagus1_ To dynamically filter rows in Power BI where all selected KPIs are equal to 0, you can use DAX to create a measure that checks the selected KPIs and filters the data accordingly. So this exactly what your are trying to do , it looks good




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






As I mentioned, I know this solution works, but it doesn’t scale well, which is important to me.

Hi @asparagus1_,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @bhanu_gautam and @wardy912 for the prompt response.

 

Based on the requirement, you can still use the unpivot approach even if you only have a parameter table and no separate KPI table in your model.

In Power Query, unpivot your KPI columns so the table has the format (Dimension, KPI, Value) using the KPI names from your parameter table so that it is fully dynamic. And when you add new KPIs to the parameter table, they are automatically included without changing the DAX.

 

After unpivoting, create a measure for example like below:

ShowRow = VAR SelectedKPIs = VALUES( Parameter[KPI] )

VAR NonZeroCount =

    CALCULATE(

        COUNTROWS(YourUnpivotedTable),

        TREATAS(SelectedKPIs, YourUnpivotedTable[KPI]),

        YourUnpivotedTable[Value] <> 0

    )

RETURN IF(NonZeroCount > 0, 1, 0)

 

This measure will return 1 for any row where at least one of the selected KPIs in the parameter table has a non-zero value.

And use ShowRow = 1 as a visual level filter. This works for any KPI selection and scales to any number of KPIs without listing combinations in DAX.

 

 

Thanks and regards,

Anjan Kumar Chippa

Hi @asparagus1_,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution I have provided for the issue worked? or let us know if you need any further assistance.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @asparagus1_,

 

We wanted to kindly follow up to check if the solution I have provided for the issue worked? or let us know if you need any further assistance.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @asparagus1_,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution I have provided for the issue worked? or let us know if you need any further assistance.

 

Thanks and regards,

Anjan Kumar Chippa

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.