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

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.

Reply
ttseng
Helper III
Helper III

How to visualize most recent known value (measure)

Hi, 

 

background:

I have a dataset that tracks school performance based on attendance that categorizes the schools into low, medium, or high performing. 

 

The dataset looks like this:

 

School_IDDatePerformancescore
1013June 20200.5Medium
1013July 20200.75Medium
1013August 20201high
1122June 202000
1122July 20200.7Medium
1122August 20200.9high
1135June 20200.6Medium
1135July 20200.6Medium
1135August 20200.70

 

I have a measure that returns the most recent known score of the schools:

 

 

 

Recent_Score = 

VAR LatestDate = 
max(attendance[Date])
VAR LatestValue =
         MAXX(
            FILTER(
                attendance,
                attendance[Date] = LatestDate
            ),
            attendance[score]
        )
Return
    LatestValue

 

 

 

This works great when used across a date slicer so that we can always determine the most recent performance of that school based on the date (over time):

 

school_perf.PNG

 

However, the issue I've run into and cannot seem to solve is that I would like to know: How many schools are performing in each category given the most recent known performance in that date period. I essentially want a stacked bar graph like below but instead of medium: 6, high:2, and 0: 1 it would show high: 2, Medium 1 based on the recent score in the matrix to the left.

school_perf_graph.PNG

 

I've attached a sample .pbix file here.

 

Help?

 

Thanks in advance.

 

 

 

 
 

 

 

1 ACCEPTED SOLUTION

@ttseng, try this measure:

 

Recent Score =
VAR vMaxDate =
    LASTDATE ( ALLSELECTED ( attendance[Date] ) )
VAR vResult =
    CALCULATE ( COUNT ( attendance[score] ), vMaxDate )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

I'd like to help.  While you already have a Score column in your dataset, could you let me know the logic of assigning scores based on the performance?  Is it that 0.76 and above is high?  PLease clearly share the lower and upper value performance figure of each score.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur ,

 

Thank you for your help.

 

The scores is supposed is based on a range:

 

"0" = "0",

<.5 = "low".

<.79 = "medium",

<= 1 = "High"

 

Thanks,

DataInsights
Super User
Super User

@ttseng, try this calculated column in the Values field well of the column chart:

 

Recent Score = 
VAR vSchool = attendance[School_ID]
VAR vSchoolTable =
    FILTER ( attendance, attendance[School_ID] = vSchool )
VAR vMaxDate =
    MAXX ( vSchoolTable, attendance[Date] )
VAR vTargetRow =
    FILTER ( vSchoolTable, attendance[Date] = vMaxDate )
VAR vResult =
    MAXX ( vTargetRow, attendance[score] )
RETURN
    IF ( attendance[Date] = vMaxDate, vResult, BLANK () )

 

DataInsights_0-1601572821757.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




HI @DataInsights ,

 

Thanks for your work on this. I tested it and it works in returning the most recent score in the whole dataset. However, when I move the date slicer to anytime before the max date it returns blank. I would like for it to return the score for the max date defined by the date slicer. The example should return a column chart with 3 for medium since those are the scores in that date range. 

school_perf_graph 2.PNG

 

Thanks in advance for helping me.

 

Hi @DataInsights,

 

Thank you! Your solution worked great!

@ttseng, try this measure:

 

Recent Score =
VAR vMaxDate =
    LASTDATE ( ALLSELECTED ( attendance[Date] ) )
VAR vResult =
    CALCULATE ( COUNT ( attendance[score] ), vMaxDate )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.