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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
FrankBuild
Frequent Visitor

Filter based on parameter (hiearchy)

Hello,

I have a matrix with 3 columns:
Organization hierarchy (3 levels) | OrgRanking | Actuals

Matrix.PNG

I have a filter in the filter (on hierarchy level) pane which gives (correct) rank 1 to 25 (or whatever I'd like to give in):
Filter pane.PNG

Now I want to hide the filter pane for the end user and I want them to choose the amount of visible items (for example top 25 or top 50).
So I have to replace the filter above. My idea was to use a parameter table (5, 100, 5) and selectedparameter. I added the Values of the Parameter table to a slicer.. 

 

But I can't get the job done... Maybe I'm thinking to difficult or it is simply difficult 😉

 

This my first post, let me know if you need more info!


Thanks, Frank


The measure of OrgRanking is as follows:

OrgRanking =
VAR _OrgLevel2_Ranking =
SUMX(
    ADDCOLUMNS(
        SUMMARIZE(
            FinanceTransactions ,
            Organization[OrgPCLevel2] ) ,
    "@Level2 Ranking" ,
    RANKX( ALL(Organization[OrgPCLevel2]), [Actuals], , DESC ) ) ,
    [@Level2 Ranking] )

VAR _OrgLevel3_Ranking =
SUMX(
    ADDCOLUMNS(
        SUMMARIZE(
            FinanceTransactions ,
            Organization[OrgPCLevel3] ) ,
    "@Level3 Ranking" ,
    RANKX( ALL(Organization[OrgPCLevel3]), [Actuals], , DESC ) ) ,
    [@Level3 Ranking] )

VAR _OrgLevel4_Ranking =
SUMX(
    ADDCOLUMNS(
        SUMMARIZE(
            FinanceTransactions ,
            Organization[OrgPCLevel4] ) ,
    "@Level4 Ranking" ,
    RANKX( ALL(Organization[OrgPCLevel4]), [Actuals], , DESC ) ) ,
    [@Level4 Ranking] )

VAR _Results =
SWITCH( TRUE() ,
    ISINSCOPE(Organization[OrgPCLevel4] ) , _OrgLevel4_Ranking ,
    ISINSCOPE(Organization[OrgPCLevel3] ) , _OrgLevel3_Ranking ,
    ISINSCOPE(Organization[OrgPCLevel2] ) , _OrgLevel2_Ranking ,
BLANK() )

RETURN
_Results    
 
Measure of selectedparemeter:

SelectedParameter = SELECTEDVALUE(ParameterTabel[Value], 25)
 
1 ACCEPTED SOLUTION
saud968
Super User
Super User

Here’s a step-by-step approach to achieve your goal:

Create a Parameter Table:
Create a table with the values you want to use for filtering (e.g., 5, 10, 15, …, 100).
Name this table ParameterTable.
Add the Parameter Table to a Slicer:
Add the ParameterTable to your report and create a slicer visual from it.
Create a Measure for the Selected Parameter:
You already have this measure:
SelectedParameter = SELECTEDVALUE(ParameterTable[Value], 25)

Modify the OrgRanking Measure:
Update your OrgRanking measure to use the selected parameter value. Here’s an example of how you can modify it:
OrgRanking =
VAR _OrgLevel2_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel2]
),
"@Level2 Ranking",
RANKX(ALL(Organization[OrgPCLevel2]), [Actuals], , DESC)
),
[@Level2 Ranking]
)

VAR _OrgLevel3_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel3]
),
"@Level3 Ranking",
RANKX(ALL(Organization[OrgPCLevel3]), [Actuals], , DESC)
),
[@Level3 Ranking]
)

VAR _OrgLevel4_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel4]
),
"@Level4 Ranking",
RANKX(ALL(Organization[OrgPCLevel4]), [Actuals], , DESC)
),
[@Level4 Ranking]
)

VAR _Results =
SWITCH(
TRUE(),
ISINSCOPE(Organization[OrgPCLevel4]), _OrgLevel4_Ranking,
ISINSCOPE(Organization[OrgPCLevel3]), _OrgLevel3_Ranking,
ISINSCOPE(Organization[OrgPCLevel2]), _OrgLevel2_Ranking,
BLANK()
)

RETURN
IF(_Results <= [SelectedParameter], _Results, BLANK())

Apply the Measure to Your Visual:
Use the modified OrgRanking measure in your matrix visual. This will ensure that only the top N items, based on the selected parameter, are displayed.

 

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

 

View solution in original post

4 REPLIES 4
FrankBuild
Frequent Visitor

Problem is solved! 😊

I kept the filter below and set the Bottom to the max of parametertable (value) which is 100 in this case.

Thank you so much!

Filterpane.PNG

 

saud968
Super User
Super User

Here’s a step-by-step approach to achieve your goal:

Create a Parameter Table:
Create a table with the values you want to use for filtering (e.g., 5, 10, 15, …, 100).
Name this table ParameterTable.
Add the Parameter Table to a Slicer:
Add the ParameterTable to your report and create a slicer visual from it.
Create a Measure for the Selected Parameter:
You already have this measure:
SelectedParameter = SELECTEDVALUE(ParameterTable[Value], 25)

Modify the OrgRanking Measure:
Update your OrgRanking measure to use the selected parameter value. Here’s an example of how you can modify it:
OrgRanking =
VAR _OrgLevel2_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel2]
),
"@Level2 Ranking",
RANKX(ALL(Organization[OrgPCLevel2]), [Actuals], , DESC)
),
[@Level2 Ranking]
)

VAR _OrgLevel3_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel3]
),
"@Level3 Ranking",
RANKX(ALL(Organization[OrgPCLevel3]), [Actuals], , DESC)
),
[@Level3 Ranking]
)

VAR _OrgLevel4_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel4]
),
"@Level4 Ranking",
RANKX(ALL(Organization[OrgPCLevel4]), [Actuals], , DESC)
),
[@Level4 Ranking]
)

VAR _Results =
SWITCH(
TRUE(),
ISINSCOPE(Organization[OrgPCLevel4]), _OrgLevel4_Ranking,
ISINSCOPE(Organization[OrgPCLevel3]), _OrgLevel3_Ranking,
ISINSCOPE(Organization[OrgPCLevel2]), _OrgLevel2_Ranking,
BLANK()
)

RETURN
IF(_Results <= [SelectedParameter], _Results, BLANK())

Apply the Measure to Your Visual:
Use the modified OrgRanking measure in your matrix visual. This will ensure that only the top N items, based on the selected parameter, are displayed.

 

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

 

Thank you Saud! 
 
The parameter (table) & slicer do work and I also see the right amount of rankings. But the organizations without a rank are also visible. I only want to see 5 organizations in this example:
 
Matrix.PNG

Regards Frank

To ensure that only the top-ranked organizations are visible and those without a rank are hidden, you can modify your measure to return BLANK() for organizations that fall outside the selected top N. Here’s how you can adjust your OrgRanking measure:

Modify the OrgRanking Measure:
Update the measure to return BLANK() for organizations that do not fall within the top N ranks.
OrgRanking =
VAR _OrgLevel2_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel2]
),
"@Level2 Ranking",
RANKX(ALL(Organization[OrgPCLevel2]), [Actuals], , DESC)
),
[@Level2 Ranking]
)

VAR _OrgLevel3_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel3]
),
"@Level3 Ranking",
RANKX(ALL(Organization[OrgPCLevel3]), [Actuals], , DESC)
),
[@Level3 Ranking]
)

VAR _OrgLevel4_Ranking =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
FinanceTransactions,
Organization[OrgPCLevel4]
),
"@Level4 Ranking",
RANKX(ALL(Organization[OrgPCLevel4]), [Actuals], , DESC)
),
[@Level4 Ranking]
)

VAR _Results =
SWITCH(
TRUE(),
ISINSCOPE(Organization[OrgPCLevel4]), _OrgLevel4_Ranking,
ISINSCOPE(Organization[OrgPCLevel3]), _OrgLevel3_Ranking,
ISINSCOPE(Organization[OrgPCLevel2]), _OrgLevel2_Ranking,
BLANK()
)

RETURN
IF(_Results <= [SelectedParameter], _Results, BLANK())

Filter the Visual:
Ensure your matrix visual is set to filter out BLANK() values. You can do this by applying a visual-level filter to exclude BLANK() values for the OrgRanking measure.


Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.