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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JustinDoh1
Post Prodigy
Post Prodigy

How do I express this in DAX? (where we have to filter multiple columns using same ID)

I have a scenario where I would like to use COUNTROWS to make a case of an existed case (as 1) so I could use in criteria inside SWTICH function clause.

 

JustinDoh1_0-1629491063742.png

 

I would like this to be case (Countrows as 1) when all these conditions are met:

1) ClientID is same

2) Step is same

3) ImmunizationDate (6/18/2021) for Consent as "Historical" > ConsentDate (5/21/2021) for Consent as "Refused" 

 

Appreciated for help!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I'm not positive how you'd like to handle all possible edge cases but I think this should get you started:

 

CountClientSteps =
VAR Summary =
    ADDCOLUMNS (
        SUMMARIZE ( Table1, Table1[ClientID], Table1[Step] ),
        "RefusedDate",
            CALCULATE ( MAX ( Table1[ConsentDate] ), Table1[Consent] = "Refused" ),
        "ImmunizedDate",
            CALCULATE ( MAX ( Table1[ImmunizationDate] ), Table1[Consent] = "Historical" )
    )
RETURN
    COUNTROWS ( FILTER ( Summary, [ImmunizedDate] > [RefusedDate] ) )

View solution in original post

2 REPLIES 2
JustinDoh1
Post Prodigy
Post Prodigy

@AlexisOlson It worked really well. Thank you so much for your help! Now, I am adding more vocabulary to DAX. Grareful for the community support 🙂

AlexisOlson
Super User
Super User

I'm not positive how you'd like to handle all possible edge cases but I think this should get you started:

 

CountClientSteps =
VAR Summary =
    ADDCOLUMNS (
        SUMMARIZE ( Table1, Table1[ClientID], Table1[Step] ),
        "RefusedDate",
            CALCULATE ( MAX ( Table1[ConsentDate] ), Table1[Consent] = "Refused" ),
        "ImmunizedDate",
            CALCULATE ( MAX ( Table1[ImmunizationDate] ), Table1[Consent] = "Historical" )
    )
RETURN
    COUNTROWS ( FILTER ( Summary, [ImmunizedDate] > [RefusedDate] ) )

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors