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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.