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

View all the Fabric Data Days sessions on demand. View schedule

Reply
AlwaysAGooner
Helper I
Helper I

DAX to Count IDs that have not retained on their previous scores

Hi,

 

I have a need to identify IDs in my data who have gone backwards on scoring and those who have retained their scores if interviewd more than once. Set of IDs (Individuals) are evaluted for a Brand and based on respnses a scoring value is assigned.

There could be a scenario where some Individuals have scored less than what they had scored previously, i.e. I scored 3 on in Apr'23 and Aug I scored 2. And then there would be case of those who have retained their scores.
All his must be responsive to date slicer, so the counting should happen only within the selected date range.

 

So to summarize, the requirements are:

 

1. Identify Ids that have scored than what they scored previously (have degraged). One such case highlighted in the image
2. Identify Ids that have retained their score

Any suggestion/leads will be greatly appreciated

AlwaysAGooner_0-1700236747804.png

 

8 REPLIES 8
AlwaysAGooner
Helper I
Helper I

Hi,

 

The code works fine. May I ask help again to also calulate 'Upgraded'? Count of those ids who have mutiple entries and have gained on the score since last evaluated, i.e. Current Score > Previous Score.

I tried making the operator change in the 'Degraded' code but that takes into account those ids as well who have been evaluted just once.

Thanks

Anonymous
Not applicable

Hi @AlwaysAGooner ,

 

Please try code as below to create measures.

IDs Retained Score = 
VAR _SCORELIST =
    SUMMARIZE (
        'Table',
        'Table'[ID],
        "Count",
            CALCULATE (
                DISTINCTCOUNT ( 'Table'[Score] ),
                ALLEXCEPT ( 'Table', DimDate[Date], 'Table'[ID] )
            )
    )
RETURN
    COUNTX ( FILTER ( _SCORELIST, [Count] = 1 ), [ID] )
Count Degraged = 
VAR _SCORELIST =
    SUMMARIZE (
        'Table',
        'Table'[ID],
        "Current",
            CALCULATE (
                SUM ( 'Table'[Score] ),
                FILTER ( 'Table', 'Table'[Date] = MAX ( 'Table'[Date] ) )
            ),
        "Previous",
            CALCULATE (
                SUM ( 'Table'[Score] ),
                FILTER (
                    'Table',
                    'Table'[Date]
                        = MAXX (
                            FILTER (
                                ALLEXCEPT ( 'Table', 'Table'[ID], DimDate[Date] ),
                                'Table'[Date] < MAX ( 'Table'[Date] )
                            ),
                            'Table'[Date]
                        )
                )
            )
    )
RETURN
    COUNTAX ( FILTER ( _SCORELIST, [Current] < [Previous] ), [ID] )

Result is as below.

vrzhoumsft_0-1700463857484.png

 

Best Regards,
Rico Zhou

 

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

 

Hi,

 

The code works fine. May I ask your help again to also calulate 'Upgraded'? Count of those ids who have mutiple entries and have gained on the score since last evaluated, i.e. Current Score > Previous Score.

I tried making the operator change in the Degraedd code but that takes into account those ids as well who have been evaluted just once.

Thanks

@Anonymous 

ThxAlot
Super User
Super User

Easy enough

ThxAlot_0-1700290950933.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Need it as a measure that would return Unquie count if IDs

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

 

Jihwan_Kim_0-1700283877951.png

 

Jihwan_Kim_1-1700284408437.png

 

Jihwan_Kim_2-1700284416398.png

 

Score measure: = 
SUM( Data[Score] )

 

Condition measure: = 
VAR _prevscore =
    CALCULATE (
        [Score measure:],
        OFFSET (
            -1,
            SUMMARIZE ( ALL ( Data ), Brand[ID], Brand[Brand], 'Calendar'[Date] ),
            ORDERBY ( 'Calendar'[Date], ASC ),
            ,
            PARTITIONBY ( Brand[Brand], Brand[ID] )
        )
    )
VAR _condition =
    IF (
        NOT ISBLANK ( [Score measure:] ),
        IF ( [Score measure:] < _prevscore, -1, 0 )
    )
RETURN
    _condition

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks for putting in efforts. I need a measure that will give me count of IDs within the selected date range. Also, do not want to create another table to use PartitionBy.

Pls suggest some other solution. Thanks 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.