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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kamalbandam
Helper III
Helper III

difference between quarters for Q1(Value1) - Q4(Value2)

Hi,

I am trying to calculate a value where I am trying to place it in a matrix visual where In columns we have Quarter, In rows we have locations and In values I need  a measure of this sort :
If it is Q1 = Q1(Value1) - Q4(Value2)
          Q2 = Q2(Value1) - Q1(Value1)

          Q3 = Q3(Value1) - Q2(Value1)

          Q4 = Q4(Value1) - Q3(Value1)
For, Q2,Q3,Q4 it's simple current quarter - previous quarter formula. But I am not getting how to get the Q1.
I have tried these dax but it wasn't working.


IF(
VALUES('Date'[date].[QuarterNo]) = 1,
[Value1] - CALCULATE([Value2],FILTER('Date',date.QuarterNo =4)
[Value1] - CALCULATE(
            [Value1],
            FILTER('Date',DATEADD(
                'Date'[date].[Date],
                -1,
                QUARTER
            )
        )))


Anything of help would be great!

Thanks in Advance!
Kamal



1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @kamalbandam ,

 

First create a calendar table as below:

dim table = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Quarter","Q"&QUARTER(''[Date]))

Then create a measure as below:

Measure = 
VAR currentquater=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Quarter]=MAX('Table'[Quarter])&&YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))))
var _previous=CALCULATE(SUM('Table'[Value]),DATEADD('dim table'[Date],-1,QUARTER))
Return
currentquater-_previous

And you will see:

vkellymsft_0-1626428297631.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

View solution in original post

1 REPLY 1
v-kelly-msft
Community Support
Community Support

Hi @kamalbandam ,

 

First create a calendar table as below:

dim table = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Quarter","Q"&QUARTER(''[Date]))

Then create a measure as below:

Measure = 
VAR currentquater=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Quarter]=MAX('Table'[Quarter])&&YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))))
var _previous=CALCULATE(SUM('Table'[Value]),DATEADD('dim table'[Date],-1,QUARTER))
Return
currentquater-_previous

And you will see:

vkellymsft_0-1626428297631.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.