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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
char23
Helper I
Helper I

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
v-yaningy-msft
Community Support
Community Support

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. 

 

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.