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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

MoM variance calc incl uniq period order

 

I have the following data structure and I have 2 question:

 

Account time amount

Revenue JAN-19 10

Revenue JAN-19 15

Revenue JAN-19 13

Revenue FEB-19 55

Revenue FEB-19 53

Cost JAN-19 5

Cost JAN-19 3

Cost JAN-19 7

Cost FEB-19 3

Cost FEB-19 1

 

Can you advise what should be the most efficient way if I want to create a measure that has a variance MoM? like example jan-19 rev is 38 vs feb -19 108=70

I also need to calculate the margin so revenue-cost=margin, how should I do that?

Since I have a lof of, data so I looking the most quicker/easy/sustainable solutions. I really appreciate the help.

 

My second question is :

When I create a matrix and put the period in the column (Jan-19, Feb-19 etc) its started to order by ABC, so it started with Aug-Apr etc. how can I create a custom order with a following:Jan-19,Feb-19,Mar-19, Apr-19 etc.

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Please  see the attached file with a solution 

 

1. I've pivoted your data so Cost and Revenue are columns now.

2. Added a simple Calendar table with Year-Month and yearMonthNo columns ( yearMonthNo column is used as a sort column to put months in the right order )

image.png

3. the below Measures will do all the requested calculations

 

Revenue MoM = 
[Revenue] -
CALCULATE( 
    SUM( 'Table'[_Revenue] ),
    DATEADD( 'Table'[time], -1, MONTH )
)
Margin = [Revenue] - [Cost]
Revenue = SUM( 'Table'[_Revenue] )

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Please  see the attached file with a solution 

 

1. I've pivoted your data so Cost and Revenue are columns now.

2. Added a simple Calendar table with Year-Month and yearMonthNo columns ( yearMonthNo column is used as a sort column to put months in the right order )

image.png

3. the below Measures will do all the requested calculations

 

Revenue MoM = 
[Revenue] -
CALCULATE( 
    SUM( 'Table'[_Revenue] ),
    DATEADD( 'Table'[time], -1, MONTH )
)
Margin = [Revenue] - [Cost]
Revenue = SUM( 'Table'[_Revenue] )

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

amitchandak
Super User
Super User

Make sure you have date table create and joined with your fact

https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions

 

formula's you can use

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date Filer]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date Filer],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date Filer],-1,MONTH))))

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date Filer])))

Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,QUARTER)))

Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,Year)))

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date Filer])))

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date Filer],-1,Year)))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors