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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Time Intelligence - WTD and MTD Previous Period

Hi. I am trying to compare some values with the previous week and previous month. I want to compare similar periods, so if the current week has only 3 days, it should compare with the first 3 days of the previous week. The same goes for the month.

 

For the week, I have this measure:

 

Weekly Evolution = (SUM(NG_Consumptions[Consumption])-CALCULATE(sum(NG_Consumptions[Consumption]),DATEADD('Calendar'[Date],-7,DAY)))/CALCULATE(sum(NG_Consumptions[Consumption]),DATEADD('Calendar'[Date],-7,DAY))

 

And it gives the value of the incomplete previous week, which is good, it compares similar periods.

 

But when I do that for the month, with the formula below, it compares the whole previous month with the current month, different periods.

 

Monthly Evolution = (TOTALMTD(sum(NG_Consumptions[Consumption]),'Calendar'[Date])-TOTALMTD(sum(NG_Consumptions[Consumption]),DATEADD('Calendar'[Date],-1,MONTH)))/TOTALMTD(sum(NG_Consumptions[Consumption]),DATEADD('Calendar'[Date],-1,MONTH))

 

Any idea why this happens?

 

Thanks!

1 ACCEPTED SOLUTION

@Anonymous

 

I find that column YearMonthNumber has not been defined in the Date Table. This should be done as 

 

YearMonthNumber = ('Calendar'[Year] - MIN( 'Calendar'[Year] )) * 12 + 'Calendar'[MonthNumber]

 

Also create a column in the Date table as Datekey = [Year]*10000+[MonthNumber]*100+Day([Date])

 

Similarly create a DateKey column in Fact table as

(Year(Factable[TransactionDate])*10000+Month(Factable[TransactionDate])*100+day(Factable[TransactionDate]) )

 

Replace the Factable by your table name and the transactiondate by the date column of the facttable. I am assuming TransactionDate is in the format ( DD/MM/YYYY) format.

 

It should work.  

 

You can try to attach a excel file with sample data or mail it srini@samiksha.com.sg

 

Let me know if this works.

 

Cheers

 

CheenuSing

 

  

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

13 REPLIES 13

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.