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
trishd1223
Frequent Visitor

Calculate % chg for Prior Period

Hi - I need to calculate % change for prior period.  I was able to do that for % chg vs Prior year, because I have two different columns - $ Sales and $ Sales Year Ago.  However, I don't have the $ Sales Prior Period column.  I have 12 different monthly periods and a $ Sales column.  So for example, I'd like to know the % Change in $ Sales from the 4 week ending 1/28/23 vs 12/31/22.  Any ideas how I would do this?  Thanks! 

 

 

   periods.png

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @trishd1223 ,

 

Please try this measure.

 

Measure = 
VAR _cur_period = MAX('Table2'[Period])
VAR _pre_period = CALCULATE(MAX('Table2'[Period]),'Table2'[Period]<_cur_period)
VAR _before_pre_period = CALCULATE(MAX('Table2'[Period]),'Table2'[Period]<_pre_period)
VAR _sale1 = CALCULATE(SUM('Table1'[Sales]),'Table1'[Date] > _before_pre_period && 'Table1'[Date] <= _pre_period)
VAR _sale2 = CALCULATE(SUM('Table1'[Sales]),'Table1'[Date] > _pre_period && 'Table1'[Date] <= _cur_period)
VAR _result = DIVIDE(_sale2-_sale1,_sale1)
RETURN
_result

 

 

Comparing different time periods – DAX Patterns

Week-related calculations – DAX Patterns

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.