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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
amit_msmba
New Member

Filter a table based on multiple conditions

Hi Friends,

 

I need help writing this measure. Here is a sample data.

Plan      Year    Amt

Plan 1   2019   30
Plan 1   2020   40
Plan 1   2021   15
Plan 2   2015   20
Plan 2   2018   20
Plan 2   2020   10

I want a DAX to return me 'Plan 1' with all the columns, as Plan 1 Year 2020 met the condition Amt > 35. The output should be like this,  How to do that?

amit_msmba_0-1671477991810.png

 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @amit_msmba ,

I created a sample pbix file(see the attachment), please check if that is what you want. You can create the measures below to get it and apply a visual-level filter on your table visual with the condition(Flag is 1😞

Sum of Amt = SUM('Table'[Amt])
Flag = 
VAR _plan =
    SELECTEDVALUE ( 'Table'[Plan] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[Plan] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Plan] = _plan && [Sum of Amt] > 35 )
    )
RETURN
    IF ( _plan IN _tab, 1, 0 )

yingyinr_0-1671517727926.png

Best Regards

Community Support Team _ Rena
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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @amit_msmba ,

I created a sample pbix file(see the attachment), please check if that is what you want. You can create the measures below to get it and apply a visual-level filter on your table visual with the condition(Flag is 1😞

Sum of Amt = SUM('Table'[Amt])
Flag = 
VAR _plan =
    SELECTEDVALUE ( 'Table'[Plan] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[Plan] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Plan] = _plan && [Sum of Amt] > 35 )
    )
RETURN
    IF ( _plan IN _tab, 1, 0 )

yingyinr_0-1671517727926.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vicky_
Super User
Super User

The lazy way is to just use a visual-level filter and set Sum of Amt > 35.
If you need it in DAX, try:

Sum of Amt = 
var sumOfAmt = SUM(Amt)
return IF(sumOfAmt > 35, sumOfAmt, BLANK())

The BLANK() is optional, but it helps with readability in my opinion.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors