Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have two tables:
I am trying to create a measure to calculate the average datediff between each students exam dates. Unfortunately, I am struggling to create a table for AVERAGEX to iterate over because I cannot create a "Prior_Exam_Date" column. See my progress below:
Average Days Between Exams:= AVERAGEX ( SUMMARIZECOLUMNS ( Student[id], Exam[Exam_Name], Exam[Exam_Date], "Prior_Exam_Date", ??? // this measure should return the most recent available Exam[Exam_Date] for the current Student[id]. ), DATEDIFF ( [Prior_Exam_Date], [Exam_Date], DAY ) )
I understand that I can easily add a physical "Prior_Exam_Date" column to my dataset to accomplish this however in this case I must calculate it on the fly. Can you please help me fill in the ??? above?
Thanks,
Simon
Solved! Go to Solution.
@Anonymous
Without using calculated column, I create some measures to get the expected result in attached sample file.
Prior_Exam_Date = CALCULATE ( MAX ( Exam[Exam_Date] ), FILTER ( ALLEXCEPT ( Exam, Exam[id] ), Exam[Exam_Date] < MAX ( Exam[Exam_Date] ) ) )
DayDiff = DATEDIFF ( [Prior_Exam_Date], CALCULATE ( MAX ( Exam[Exam_Date] ) ), DAY )
Average_DayDiff = AVERAGEX ( ALLEXCEPT ( Exam, Exam[id] ), [DayDiff] )
Best Regards,
Herbert
@Anonymous
Without using calculated column, I create some measures to get the expected result in attached sample file.
Prior_Exam_Date = CALCULATE ( MAX ( Exam[Exam_Date] ), FILTER ( ALLEXCEPT ( Exam, Exam[id] ), Exam[Exam_Date] < MAX ( Exam[Exam_Date] ) ) )
DayDiff = DATEDIFF ( [Prior_Exam_Date], CALCULATE ( MAX ( Exam[Exam_Date] ) ), DAY )
Average_DayDiff = AVERAGEX ( ALLEXCEPT ( Exam, Exam[id] ), [DayDiff] )
Best Regards,
Herbert
Hi @Anonymous,
Could you please send ( share) dummy data with expected results and then we can test different approaches.
Thank you.
Ninter
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |