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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.