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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shoeb1359
Helper III
Helper III

Latest Data visualization based on filter selection

Hello Experts
I have a scenario where I need to display total no of students enrolled in different schools, with a month filter (multi-select).
Challenge here is, some students got transferred from one school to another during the year. When we visualize no of students by school, the transferred students are counted more than once. End user is requesting for "no of students by school" visual to consider students latest enrollment when no filter is selected, but if month filter is selected, he/she wants to see the exact count for that month, even if the student is not enrolled currently in that school

Month YearSchool NameStudent idIsCurrent
Jan-23A101No
Feb-23B102No
Mar-23C101Yes
Apr-23D102Yes



shoeb1359_1-1728302432543.png

 

v-zhangti

1 ACCEPTED SOLUTION
qqqqqwwwweeerrr
Super User
Super User

Hi @shoeb1359 

 

You can achieve this by creating three measure

1. 

Latest Enrollment =
CALCULATE(
    COUNTROWS(
        DISTINCT('Enrollment'[Student id])
    ),
    FILTER(
        'Enrollment',
        'Enrollment'[IsCurrent] = "Yes"
    )
)
2. 
Students Per Month =
CALCULATE(
    COUNTROWS(
        DISTINCT('Enrollment'[Student id])
    ),
    REMOVEFILTERS('Enrollment'[IsCurrent])
)
3. 
Final Student Count =
IF(
    ISFILTERED('Enrollment'[Month Year]),
    [Students Per Month],
    [Latest Enrollment]
)use thired meaure in axis of a chart here is the output 
when nothing is selected the latest one be is shown
qqqqqwwwweeerrr_0-1728306142494.png

when selected in filter

qqqqqwwwweeerrr_1-1728306164592.png

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Check for more intersing solution here: www.youtube.com/@Howtosolveprobem

Regards

View solution in original post

2 REPLIES 2
shoeb1359
Helper III
Helper III

Thanks it's working . Keep up the good work

qqqqqwwwweeerrr
Super User
Super User

Hi @shoeb1359 

 

You can achieve this by creating three measure

1. 

Latest Enrollment =
CALCULATE(
    COUNTROWS(
        DISTINCT('Enrollment'[Student id])
    ),
    FILTER(
        'Enrollment',
        'Enrollment'[IsCurrent] = "Yes"
    )
)
2. 
Students Per Month =
CALCULATE(
    COUNTROWS(
        DISTINCT('Enrollment'[Student id])
    ),
    REMOVEFILTERS('Enrollment'[IsCurrent])
)
3. 
Final Student Count =
IF(
    ISFILTERED('Enrollment'[Month Year]),
    [Students Per Month],
    [Latest Enrollment]
)use thired meaure in axis of a chart here is the output 
when nothing is selected the latest one be is shown
qqqqqwwwweeerrr_0-1728306142494.png

when selected in filter

qqqqqwwwweeerrr_1-1728306164592.png

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Check for more intersing solution here: www.youtube.com/@Howtosolveprobem

Regards

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.