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
Anonymous
Not applicable

Calculate a measure based on 2 conditions in a group by

Greeting lovely members 

here is a sample table that i choose for my problem : 

 

Student IDStatusYear
1Refused2021
1Refused2021
1Accepted2020
2Accepted2021
2Refused2021
2Refused2021
3Refused2021
3Refused2021
3Refused2021
4Refused2020
5Accepted2021
5Refused2021


 
im trying to calculate the number of student who got rejected in all their status starting from 2021 . 

So my input will be 2 : Student number 1 and student number 3 

 

Anyone can help me with this trick ? thanks in advance.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try a measure like


countx(filter(summarize(Table, Table[Student Id], "_1", countx(filter(Table[Year] =2021), [Student ID]), "_2", countx(filter(Table[Year] =2021 && [Status] ="Refused" ), [Student ID])), [_1] =[_2]),[Student Id])

View solution in original post

v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try the following formula to creata a measure:

Flag =
VAR _count =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            'Table',
            'Table'[Year] >= 2021
                && 'Table'[Student ID] = MAX ( 'Table'[Student ID] )
        )
    ) + 0
VAR _a =
    COUNTX (
        FILTER (
            'Table',
            'Table'[Student ID] = MAX ( 'Table'[Student ID] )
                && 'Table'[Status] = "Refused"
        ),
        _count
    )
RETURN
    IF ( _count = _a && _count <> 0, 1, 0 )

Then apply it to filter pane, here is the final output:

all status are refused.PNG


Best Regards,
Eyelyn Qin
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-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try the following formula to creata a measure:

Flag =
VAR _count =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            'Table',
            'Table'[Year] >= 2021
                && 'Table'[Student ID] = MAX ( 'Table'[Student ID] )
        )
    ) + 0
VAR _a =
    COUNTX (
        FILTER (
            'Table',
            'Table'[Student ID] = MAX ( 'Table'[Student ID] )
                && 'Table'[Status] = "Refused"
        ),
        _count
    )
RETURN
    IF ( _count = _a && _count <> 0, 1, 0 )

Then apply it to filter pane, here is the final output:

all status are refused.PNG


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

amitchandak
Super User
Super User

@Anonymous , Try a measure like


countx(filter(summarize(Table, Table[Student Id], "_1", countx(filter(Table[Year] =2021), [Student ID]), "_2", countx(filter(Table[Year] =2021 && [Status] ="Refused" ), [Student ID])), [_1] =[_2]),[Student Id])

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.