cancel
Showing results for
Did you mean:
Community Champion

How can I calculate the difference of scores between previous quarter and current quarter

 Date Category Score 01-01-2016 A 3 01-01-2016 B 2 01-01-2016 C 4 04-04-2016 A 2.5 04-04-2016 B 2.5 04-04-2016 C 4 08-08-2016 A 2 08-08-2016 B 3 08-08-2016 C 2 12-12-2016 A 3 12-12-2016 B 3 12-12-2016 C 3 02-02-2017 A 3 02-02-2017 B 2 02-02-2017 C 4 06-06-2017 A 3.5 06-06-2017 B 2 06-06-2017 C 2.5

In this table contain quarterly scores of different categories. How can i calculate the difference between previous quarter and current quarter in a calculated column.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion

Re: How can I calculate the difference of scores between previous quarter and current quarter

I got the Dax query. Below query works for me.

```CurrentQuarterScore-PreviousQuarterScore =
VAR currentQuarterScore =
CALCULATE ( SELECTEDVALUE ( Table1[Score] ) )
VAR selectedCategory =
SELECTEDVALUE ( Table1[Category] )
VAR previousQuarterScore =
CALCULATE (
SUM ( Table1[Score] ),
ALLEXCEPT ( Table1, Table1[Category] ),
PREVIOUSQUARTER ( Table1[Date] )
)
VAR difference =
CALCULATE ( currentQuarterScore - previousQuarterScore )
RETURN
difference```
3 REPLIES 3
Community Support

Re: How can I calculate the difference of scores between previous quarter and current quarter

You can create a calculated column below:

QuarterDiff(current-previous) = TOTALQTD(SUM('Table1'[Score]),'Table1'[Date],ALL(Table1))-CALCULATE(SUM(Table1[Score]),ALL(Table1),PREVIOUSQUARTER('Table1'[Date]))

Best Regards,
Qiuyun Yu
Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Community Champion

Re: How can I calculate the difference of scores between previous quarter and current quarter

It seems results are not correct.

Expected values are mentioned in red color

Highlighted
Community Champion

Re: How can I calculate the difference of scores between previous quarter and current quarter

I got the Dax query. Below query works for me.

```CurrentQuarterScore-PreviousQuarterScore =
VAR currentQuarterScore =
CALCULATE ( SELECTEDVALUE ( Table1[Score] ) )
VAR selectedCategory =
SELECTEDVALUE ( Table1[Category] )
VAR previousQuarterScore =
CALCULATE (
SUM ( Table1[Score] ),
ALLEXCEPT ( Table1, Table1[Category] ),
PREVIOUSQUARTER ( Table1[Date] )
)
VAR difference =
CALCULATE ( currentQuarterScore - previousQuarterScore )
RETURN
difference```

Announcements

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ Integration Forum Launch

We've launched a how-to forum where you can learn about how Power BI integrates with other Power Platform products.

Top Solution Authors
Top Kudoed Authors