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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Top and top -1 values of list dynamically

Hello all,

 

I have a list of persons that have a score and a date of that score. Now I want to create a table in powerbi desktop with a bunch of things including their latest score and the score they have gotten before that dynamically.

 

I have this sample set:

Maya9/21/20225.4
Robbert9/20/20225
Vince9/20/20223.4
Vince3/12/20213.6
Vince6/5/20223.7
Robbert9/12/20222.9
Robbert5/5/20215.6
Lisa6/12/20229.9
Vince7/12/202219.2
Lisa8/20/20222.1

 

The result i would want to be like this:

MayaDepartment 1Address5.4NULL/EMPTY/0
RobbertDepartment 2Address52.9
VinceDepartment 2Address19.23.4
LisaDepartment 3Address2.19.9

 

I've looked into ranking etc, but i can't quite figure out how to do it in this specific context also because I want to put it in a table with other info.
When new data is added in the sample set i'd like it to automatically still pick the " top" and " top -1" value in the table.

 

If any more info is req let me know!

Thx!

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Use these measures:

 

Score on last date =
VAR _LastDate =
    CALCULATE ( MAX ( fTable[Date] ), ALLEXCEPT ( fTable, fTable[Employee] ) )
RETURN
    CALCULATE (
        SUM ( fTable[Score] ),
        FILTER ( ALLEXCEPT ( fTable, fTable[Employee] ), fTable[Date] = _LastDate )
    )
Score on last date -1 =
VAR _LastDate =
    CALCULATE ( MAX ( fTable[Date] ), ALLEXCEPT ( fTable, fTable[Employee] ) )
VAR _PrevDate =
    CALCULATE (
        MAX ( fTable[Date] ),
        FILTER ( ALLEXCEPT ( fTable, fTable[Employee] ), fTable[Date] < _LastDate )
    )
RETURN
    CALCULATE (
        SUM ( fTable[Score] ),
        FILTER ( ALLEXCEPT ( fTable, fTable[Employee] ), fTable[Date] = _PrevDate )
    )

 

result.png

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

Use these measures:

 

Score on last date =
VAR _LastDate =
    CALCULATE ( MAX ( fTable[Date] ), ALLEXCEPT ( fTable, fTable[Employee] ) )
RETURN
    CALCULATE (
        SUM ( fTable[Score] ),
        FILTER ( ALLEXCEPT ( fTable, fTable[Employee] ), fTable[Date] = _LastDate )
    )
Score on last date -1 =
VAR _LastDate =
    CALCULATE ( MAX ( fTable[Date] ), ALLEXCEPT ( fTable, fTable[Employee] ) )
VAR _PrevDate =
    CALCULATE (
        MAX ( fTable[Date] ),
        FILTER ( ALLEXCEPT ( fTable, fTable[Employee] ), fTable[Date] < _LastDate )
    )
RETURN
    CALCULATE (
        SUM ( fTable[Score] ),
        FILTER ( ALLEXCEPT ( fTable, fTable[Employee] ), fTable[Date] = _PrevDate )
    )

 

result.png

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






AUDISU
Resolver III
Resolver III

@Anonymous 

Hi,

There is no Depatment and Address in your sample table. How did you get that?

Do you have that data in same table?

Thanks

Anonymous
Not applicable

Hey, the department etc is just an example of other info in my table. the measure is only about the last scores that i want to " append" to my existing table in powerbi. The data model is set up so there is a relationship between an employee and a score so it can get a score per employee. But i want the last and second to last score per employee based on the lastest date of the score if that makes sense.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors