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
MarkSmash
Frequent Visitor

Measure for Unique Records from Previous Term

Hello,

 

I'm looking to get a measure, "Unique Students Last Year," which would be the number of unique records from the previous term (in this case a term is a school year). The scores are based on the school year, and aren't tied to a specific date for regular time intelligence functions.

 

End result wanted in a table:

School Year NameUnique StudentsUnique Students Last Year
2020-214 
2021-2224
2022-2312

 

Simplified model:

SimpleModel.JPG

 

Sample Data:

 

SchoolYear table:

SchoolYearKeySchool Year NameOrder
12020-21-2
22021-22-1
32022-230

 

 

TestScores table:

ScoreKeyScoreStudentSubjectSchoolYearKey
1101001Math1
5151001Math2
4161004Math1
3171003Math1
8181001English1
2201002Math1
6201002Math2
7201001Math3
9201001English2

 

 

Thanks!

1 ACCEPTED SOLUTION
speedramps
Super User
Super User

Click here to download the solution
Download PBIX 

speedramps_0-1698871280136.png


How iit works ...

Students this year = 
DISTINCTCOUNT(TestScores[Student])

 

Students previous year = 
VAR thisref= SELECTEDVALUE(SchoolYear[Order])
VAR previousref= thisref - 1
RETURN
CALCULATE(
DISTINCTCOUNT(TestScores[Student]),
ALL(SchoolYear),
SchoolYear[Order] = previousref)

 

Please click both  the ACCCEPT SOLUTION button and the thumbs up buttons.

If you need more help then please raise a new ticket and quote @speedramps 
I will receive an automated notifcation and will try help

 

View solution in original post

3 REPLIES 3
speedramps
Super User
Super User

Thank you for the kudos.
If you need more help then raise a new ticket and quote @speedramps anywhere in the text,  I will then receive an automatic notification and will be delighted to help you again.
Please always try provide example input data as table text (not a screen print) so we can import the data to build a solution for you. You will gain respect and a much quicker and better responses with the more effort put in to describing problems  

speedramps
Super User
Super User

Click here to download the solution
Download PBIX 

speedramps_0-1698871280136.png


How iit works ...

Students this year = 
DISTINCTCOUNT(TestScores[Student])

 

Students previous year = 
VAR thisref= SELECTEDVALUE(SchoolYear[Order])
VAR previousref= thisref - 1
RETURN
CALCULATE(
DISTINCTCOUNT(TestScores[Student]),
ALL(SchoolYear),
SchoolYear[Order] = previousref)

 

Please click both  the ACCCEPT SOLUTION button and the thumbs up buttons.

If you need more help then please raise a new ticket and quote @speedramps 
I will receive an automated notifcation and will try help

 

Ahh--All(SchoolYear) was the missing piece for me. Thanks for the quick response!

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.