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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Create a slicer using a measure to filter selected value

Hi Guys, I'm working on a table with last year two period and this year two period datas.

 

I want to create a slicer using column[ Products] to see this session's Region Level 2 and last session's Region Level 1 comparison, which means I have two conditions to consider.

 

So I have five colomuns to consider, and also other columns like SALES, comments and others to show in the table visual.

ProductsRegionRegion LevelSessionIndexSalesComments
Product AHeadquarter12022 Annual1  
Product AWest22022 Annual1  
Product B East22022 Annual1  
Product CHeadquarter12022 Annual1  
Product AHeadquarter12023 Interim2  
Product B West22023 Interim2  
Product CWest22023 Interim2  
Product AWest22023 Annual3  
Product B Headquarter12023 Annual3  
Product CHeadquarter12023 Annual3  

 

WangLuo_0-1688943404309.png

picture 

 

Because I have more than twenty products in the database.

 

Can it work when I choose Product A it would show the value of both this session's Level 2 and Last session's level 1 data?

 

I added a column index for 2022 Annual as 1, 2023 Interim as 2, 2023 Annual as 3. would be more index in the future.

I create a measure Using following:

Second Filter =
VAR selectlevel = SELECTEDVALUE(Table1[Region Level])
VAR selectsession = SELECTEDVALUE(Table1[Index])
RETURN
SWITCH(
    TRUE(),
    selectlevel = "1" && selectsession = selectsession-1,1,
    selectlevel = "2" && selectsession = selectsession,1,
    0)



But it shows ERROR.

So is it possible to create a dynamic measure to use in the slicer filter?

 

 

Thank you all.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Directly filter with a slicer to obtain the following

vstephenmsft_1-1689040063260.png

If the above method is not what you want, you want to compare on the same line, such as comparing the sales of level 1 and level 2 under the same session. Then your index needs to be created as follows:

Group by Session column and add a All Rows column.

vstephenmsft_2-1689040223744.png

vstephenmsft_3-1689040261470.png

Add a custom column to add index and then expand it.

vstephenmsft_4-1689040282599.png

vstephenmsft_5-1689040323019.png

Create a measure to get level 1 sales.

level 1 sales = CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Table'),[Session]=MAX('Table'[Session])&&[Region Level]=MAX('Table'[Region Level])-1))

vstephenmsft_6-1689040704864.png

 

   

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

Directly filter with a slicer to obtain the following

vstephenmsft_1-1689040063260.png

If the above method is not what you want, you want to compare on the same line, such as comparing the sales of level 1 and level 2 under the same session. Then your index needs to be created as follows:

Group by Session column and add a All Rows column.

vstephenmsft_2-1689040223744.png

vstephenmsft_3-1689040261470.png

Add a custom column to add index and then expand it.

vstephenmsft_4-1689040282599.png

vstephenmsft_5-1689040323019.png

Create a measure to get level 1 sales.

level 1 sales = CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Table'),[Session]=MAX('Table'[Session])&&[Region Level]=MAX('Table'[Region Level])-1))

vstephenmsft_6-1689040704864.png

 

   

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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