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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculated Column - Return Previous Score based on Multiple Column Criteria

Hi,

 

I have survey results across multiple Clients and Criteria. These surveys take place at different Cycles during the year. I want to be able to work out the difference in score between each Cycle for each Client and Criteria. I initially did this using measures, which all worked fine. But there's a requirement to have a Legend on the report identifying where results have Increased or Decreased. As I'm not able to put a Measure into a Legend I need to create Calculated Columns to get to my answer.

 

If I use the following DAX to get the Client and Critieria scores for each Cycle:

 

Score - Average by Criteria = CALCULATE([Score - Average, Overall],ALLEXCEPT('Pulse - Results','Pulse - Results'[Client],'Pulse - Results'[Criteria],'Pulse - Results'[Cycle]))
 
What I'd like to do it work out a Calculated Column that returns the score for each Client and Criteria for the previous Cycle - these are number values.
 
Any ideas on how I do this? I was thinking I would use EARLIER but I'm not sure how to apply this.

 

Thanks,

MarkJames

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Anonymous 

If you just want to modify the code you posted to filter on the previous cycle (assuming it is 1 less than current cycle), then here are a few different expressions that should work in a calculated column. The only difference is the way the Cycle filter is created:

 

Score - Average by Criteria (previous cycle) =
CALCULATE (
    [Score - Average, Overall],
    ALLEXCEPT (
        'Pulse - Results',
        'Pulse - Results'[Client],
        'Pulse - Results'[Criteria]
    ),
    TREATAS ( { 'Pulse - Results'[Cycle] - 1 }, 'Pulse - Results'[Cycle] )
)
Score - Average by Criteria (previous cycle) =
CALCULATE ( 
    [Score - Average, Overall],
    ALLEXCEPT (
        'Pulse - Results',
        'Pulse - Results'[Client],
        'Pulse - Results'[Criteria]
    ),
   'Pulse - Results'[Cycle] = EARLIER ( 'Pulse - Results'[Cycle] ) - 1
)
Score - Average by Criteria (previous cycle) =
VAR CurrentCycle = 'Pulse - Results'[Cycle]
RETURN
    CALCULATE (
        [Score - Average, Overall],
        ALLEXCEPT (
            'Pulse - Results',
            'Pulse - Results'[Client],
            'Pulse - Results'[Criteria]
        ),
        'Pulse - Results'[Cycle] = CurrentCycle - 1
    )

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @Anonymous 

If you just want to modify the code you posted to filter on the previous cycle (assuming it is 1 less than current cycle), then here are a few different expressions that should work in a calculated column. The only difference is the way the Cycle filter is created:

 

Score - Average by Criteria (previous cycle) =
CALCULATE (
    [Score - Average, Overall],
    ALLEXCEPT (
        'Pulse - Results',
        'Pulse - Results'[Client],
        'Pulse - Results'[Criteria]
    ),
    TREATAS ( { 'Pulse - Results'[Cycle] - 1 }, 'Pulse - Results'[Cycle] )
)
Score - Average by Criteria (previous cycle) =
CALCULATE ( 
    [Score - Average, Overall],
    ALLEXCEPT (
        'Pulse - Results',
        'Pulse - Results'[Client],
        'Pulse - Results'[Criteria]
    ),
   'Pulse - Results'[Cycle] = EARLIER ( 'Pulse - Results'[Cycle] ) - 1
)
Score - Average by Criteria (previous cycle) =
VAR CurrentCycle = 'Pulse - Results'[Cycle]
RETURN
    CALCULATE (
        [Score - Average, Overall],
        ALLEXCEPT (
            'Pulse - Results',
            'Pulse - Results'[Client],
            'Pulse - Results'[Criteria]
        ),
        'Pulse - Results'[Cycle] = CurrentCycle - 1
    )

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
Anonymous
Not applicable

Thanks @OwenAuger , this has worked an absolute treat.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.