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
xiumi_hou
Post Partisan
Post Partisan

Need help for dax funtion to sort the current score

Dear all,

 

1. I want to find the current session score (or the lastest session date's score for a single person), below dax give my blank() result:

 

Current Score = CALCULATE( SELECTEDVALUE(Score Table[SCORE]),
filter(Score Table,
max(Score Table[Session date])
)
)
 
by the way, I have a filter to for employee id for a single person
2. I want to calculate the increase percentage (For example, I have session date 1,2,3, 3 is the newest one. I want to calculate the percentage increase for date 3 from date 2), I do not know how to wrtite. Thanks
My table like this:454.JPG
 
 
 


1 ACCEPTED SOLUTION

Hi @xiumi_hou ,

I created a sample that you can try and check if is what you want.

Newest score = 
var max_date = CALCULATE(MAX('Table'[Session date]),ALLEXCEPT('Table','Table'[EMPLOYEE Id]))
return
CALCULATE(SUM('Table'[SCORE]),FILTER('Table','Table'[Session date] = max_date))

Increase = 
var max_date = CALCULATE(MAX('Table'[Session date]),ALLEXCEPT('Table','Table'[EMPLOYEE Id]))
var last_score = CALCULATE(SUM('Table'[SCORE]),FILTER(ALLEXCEPT('Table','Table'[EMPLOYEE Id]),'Table'[Session date] = MAX('Table'[Session date]) - 1))
var percentage = DIVIDE([Newest score] - last_score,last_score)
return
IF(MAX('Table'[Session date]) = max_date,percentage,BLANK())

Note : They are both measures. 

5.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Kudos are nice too.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Nathaniel_C
Super User
Super User

Hi @xiumi_hou ,

Would you be able to give us an example of your expected outcome and copy and paste the table you have in the picture? It would be good if you could copy and paste the values in the message rather than a picture, even if you have to dummy one up in Excel.  
Please read this post to get your question answered more quickly:

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

Thank you,

Nathaniel





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

Proud to be a Super User!




@Nathaniel_C 

Thanks for answering.

I need two calculations:

1. When I filter employee 1, I want to add a new column or a measure to show the newest score. (In this table should be 8

2.I want to see whether this employee improved or not. So I will compare the most recent two dates, the percentage i am expecting is (8-4)/4*100%

 

Below is my data:

EMPLOYEE IdSession dateSCORE
14/5/20182
14/6/20184
14/7/20188
24/4/20182
24/5/20181
24/6/20187
34/7/20186

Hi @xiumi_hou ,

I created a sample that you can try and check if is what you want.

Newest score = 
var max_date = CALCULATE(MAX('Table'[Session date]),ALLEXCEPT('Table','Table'[EMPLOYEE Id]))
return
CALCULATE(SUM('Table'[SCORE]),FILTER('Table','Table'[Session date] = max_date))

Increase = 
var max_date = CALCULATE(MAX('Table'[Session date]),ALLEXCEPT('Table','Table'[EMPLOYEE Id]))
var last_score = CALCULATE(SUM('Table'[SCORE]),FILTER(ALLEXCEPT('Table','Table'[EMPLOYEE Id]),'Table'[Session date] = MAX('Table'[Session date]) - 1))
var percentage = DIVIDE([Newest score] - last_score,last_score)
return
IF(MAX('Table'[Session date]) = max_date,percentage,BLANK())

Note : They are both measures. 

5.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Kudos are nice too.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.