Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I am new to using DAX. I want to get the retention rate of students (identified with StuID) who return from one year to the next year, along with the number of students who do not return. To track a specific cohort, I need to use "Curr enr" codes F1 or F2 in year one, but the student will be code C during their second, third, and fourth year, etc. It needs to be a distinct count because there can be multiple StuID records within one Year. Could someone help me with a formula that will track students from one year to the next and help me find a retention rate?
Hi @rmaxfield ,
I created some data:
Here are the steps you can follow:
1. Create measure.
Rank =
RANKX(
ALL('Table'),CALCULATE(SUM('Table'[Year])),,ASC,Dense)
Measure =
SWITCH(
TRUE(),
'Table'[Rank]=MINX(ALL('Table'),[Rank]),
CALCULATE(
DISTINCTCOUNT('Table'[StuID]),
FILTER(ALL('Table'),
'Table'[Rank]=MINX(ALL('Table'),[Rank])&&OR('Table'[Current]="F1",'Table'[Current]="F2")))
,
'Table'[Rank]>=MINX(ALL('Table'),[Rank])+1&&'Table'[Rank]<=MINX(ALL('Table'),[Rank])+3,
CALCULATE(
DISTINCTCOUNT('Table'[StuID]),
FILTER(ALL('Table'),
'Table'[Rank]>=MINX(ALL('Table'),[Rank])+1&&'Table'[Rank]<=MINX(ALL('Table'),[Rank])+3&&'Table'[Current]="C"&&'Table'[Year]=MAX('Table'[Year]))))
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hello, thank you so much for your data suggestion. Would you please explain what the second Measure (using SWITCH) will calculate for me in this dataset?
Also, I find no error in my formula, but my Measure is coming out blank.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.