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
CLANG10
Helper I
Helper I

DAX on Quarter to Quarter comparison

Hi,

   Would like to seek advise on how to write DAX measure to compare Current quarter average % change Vs previous quarter % change.

 

I tried to write as:

Current quarter = CALCULATE([% change], FILTER(Max[QUARTER])  

Previous quarter = CALCULATE([% change], FILTER(Max[QUARTER]-1)  

Difference = Current quarter - Previous quarter

But it doesn't work, as writing this way, it seems to intepret that if current quarter = 202301, then previous quarter= 202300 instead of 202212

 

Thanks for advise!

 

QUARTERMONTHACTUAL_DATE% change
2022032022088/26/2022 0:00100%
2022032022098/29/2022 0:00100%
2022032022098/30/2022 0:0050%
2022032022098/31/2022 0:00100%
2022032022099/1/2022 0:00100%
2022032022099/2/2022 0:00100%
2022032022099/5/2022 0:00100%
2022032022099/6/2022 0:00100%
2022032022099/7/2022 0:000%
20220420221111/25/2022 0:0050%
20220420221211/28/2022 0:00100%
20220420221212/17/2022 0:00100%
20220420221212/20/2022 0:00100%
20220420221212/21/2022 0:0075%
20220420221212/22/2022 0:00100%
20220420221212/27/2022 0:0050%
20220420221212/28/2022 0:00100%
2023012023011/3/2023 0:00100%
2023012023011/4/2023 0:00100%
2023012023011/6/2023 0:0067%
2023012023022/24/2023 0:00100%
2023012023033/17/2023 0:00100%
2023012023033/20/2023 0:0050%
2023012023033/21/2023 0:00100%
2023012023033/22/2023 0:00100%
2023012023033/23/2023 0:000%
2023012023033/24/2023 0:0067%
2023012023033/28/2023 0:00100%
2023012023033/29/2023 0:00100%
2023012023033/30/2023 0:00100%
2023012023033/31/2023 0:00100%
2023022023044/2/2023 0:00100%
1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi  @CLANG10 ,

 

Here are the steps you can follow:

1.Create a calculated column.

 

QUARTER_Number = QUARTER('Table'[ACTUAL_DATE])

 

2.Create  measures.

 

Current_Avg =

AVERAGEX(

   FILTER(ALL('Table'),

   'Table'[QUARTER]=MAX('Table'[QUARTER])),[% change])
Previous_Sum =

var _date=

DATE(

   YEAR(MAX('Table'[ACTUAL_DATE]))-1,12,1)

var _lastdate=

VALUE(YEAR(_date)&"0"&QUARTER(_date))

return

IF(

   MAX('Table'[QUARTER_Number])=1,

  SUMX(

      FILTER(ALL('Table'),

      'Table'[QUARTER]=_lastdate),[% change]),

      SUMX(

          FILTER(ALL('Table'),

          'Table'[QUARTER]=MAX('Table'[QUARTER])-1),[% change]))

 

3.Then the result is as follows.

vtangjiemsft_0-1680683698173.png

Best Regards,

Neeko Tang

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

 

 

View solution in original post

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi  @CLANG10 ,

 

Here are the steps you can follow:

1.Create a calculated column.

 

QUARTER_Number = QUARTER('Table'[ACTUAL_DATE])

 

2.Create  measures.

 

Current_Avg =

AVERAGEX(

   FILTER(ALL('Table'),

   'Table'[QUARTER]=MAX('Table'[QUARTER])),[% change])
Previous_Sum =

var _date=

DATE(

   YEAR(MAX('Table'[ACTUAL_DATE]))-1,12,1)

var _lastdate=

VALUE(YEAR(_date)&"0"&QUARTER(_date))

return

IF(

   MAX('Table'[QUARTER_Number])=1,

  SUMX(

      FILTER(ALL('Table'),

      'Table'[QUARTER]=_lastdate),[% change]),

      SUMX(

          FILTER(ALL('Table'),

          'Table'[QUARTER]=MAX('Table'[QUARTER])-1),[% change]))

 

3.Then the result is as follows.

vtangjiemsft_0-1680683698173.png

Best Regards,

Neeko Tang

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

 

 

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.