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
char23
Helper II
Helper II

How to filter table with value related to the selectedvalue

I have the two tables below in my power bi file. I have a slicer from Table2 that uses column [Month] as the selected value. If a month is selected, I want to calculate and filter Table1 where Table1 = the associated selected [Date Rank] from Table2 + 1. For example, if 24-Jun is selected from Table2, I want to filter Table1 where [Month] = 24-May.

 

Table1

IDStatusDate RankPrevious StatusMonthTypeGroup
ANormal3No previous24-MarTask<0
BNormal3No previous24-MarTask1 to 5
CNot Normal3No previous24-MarTask1 to 5
DNot Normal3No Previous24-MarNot Task11 to 15
ANot Normal2Normal24-MayTask6 to 10
BNormal2Normal24-MayNot Task6 to 10 
CNormal2Not Normal24-MayNot Task6 to 10
DNot Normal2Not Normal24-MayTask6 to 10
ANot Normal1Not Normal24-JunTask1 to 5
BNot Normal1Normal24-JunTask<0
DNormal1Normal24-JunTask<0
ENormal1 24-JunTask1 to 5

 

Table2

Date RankMonth
324-Mar
224-May
124-Jun
5 REPLIES 5
Anonymous
Not applicable

Hi, @char23 

Thanks for lbendlin‘s reply. You can put this measure in filter pane and set to 1 to filter data.

vyaningymsft_0-1723430018021.png

vyaningymsft_1-1723430093687.png

filter =
VAR _month =
    SELECTEDVALUE ( 'Table 2'[Month] )
VAR _dateRank =
    CALCULATE (
        MAXX ( 'Table 2', 'Table 2'[Date Rank] ) + 1,
        FILTER ( 'Table', 'Table'[Month] = _month )
    )
VAR _result =
    IF ( SELECTEDVALUE ( 'Table'[Date Rank] ) = _dateRank, 1 )
RETURN
    _result


Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

Thank you, I'm not sure if this would work for my visual since I have other measures on the same visual. Is there anyway to write this where the filter for 1 is in the measure itself? I am trying to understand how your formula works. 

 

Anonymous
Not applicable

Hi, @char23 

The logic of this formula is to find the corresponding Date Rank of Table 2 according to the selected date and add 1. If the Date Rank of Table 1 is the same as the corresponding Date Rank of Table 2, then the Flag will be 1, otherwise, it will be 0. Add this Measure to the Filter box of the visual object, and set it to 1, then it will display all rows that have a filter of 1. What are the main problems you are currently facing that you can mark with a picture.

Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. 
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

lbendlin
Super User
Super User

Add another column to Table2, call it "Next Date Rank", and set it to [Date]+1.  Use that column to join to Table1.

Thank you for the suggestion. Can you elaborate. I tried this method and still haveing trouble getting it to work. This is what I have below, but it just returns blank. 

 

VAR SelectedNextDateRank =
    CALCULATE(
        MAX('Table2'[Next Date Rank]),
        'Table2'[Month] = SELECTEDVALUE('Table2'[Month])
    )
RETURN
    COUNTROWS(
        CALCULATETABLE(
            'Table1',
            'Table1'[Date Rank] = SelectedNextDateRank
        )
    )

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.