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

Comparing variations between actual month and last month

Hello everybody, 

 

I am trying to get the variations between the revenue of the current month and the last one, but only these two without including the rest of the date in the data.

 

So I tried 

currentmonthsum  = TOTALMTD([Original Value SUM];Revenue[Date];DATESBETWEEN(Revenue[Date];01;31)) 
 
It's doenst work apparentely, could someone guide me?
1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

You need a date dimention table first. Also, add a calculated column [index] in it.

Date = CALENDAR(MIN(Revenue[Date]),MAX(Revenue[Date]) )

index = RANKX('Date',YEAR([Date])*100+MONTH([Date]),,ASC,Dense)
 
Establish a one to many relationship from date table to Revenue table based on [date] field.
 
Then, add 'Date'[Date] and below two measures into table visual.
TM revenue = SUM(Revenue[Amount])

LM revenue = CALCULATE([TM revenue],FILTER(ALLSELECTED('Date'),'Date'[index]=MAX('Date'[index])-1))
1.PNG
 
Best regards,
Yuliana Gu
Community Support Team _ Yuliana Gu
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

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

You need a date dimention table first. Also, add a calculated column [index] in it.

Date = CALENDAR(MIN(Revenue[Date]),MAX(Revenue[Date]) )

index = RANKX('Date',YEAR([Date])*100+MONTH([Date]),,ASC,Dense)
 
Establish a one to many relationship from date table to Revenue table based on [date] field.
 
Then, add 'Date'[Date] and below two measures into table visual.
TM revenue = SUM(Revenue[Amount])

LM revenue = CALCULATE([TM revenue],FILTER(ALLSELECTED('Date'),'Date'[index]=MAX('Date'[index])-1))
1.PNG
 
Best regards,
Yuliana Gu
Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

See if my Time Intelligence The Hard Way gets you what you need: https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Good information, but still didnt resolve my problem. I need to sum the revenue of this month, and compare to the last month revenue sum, and then see the variaton. Thanks

That's a very minor variation on those formulas. I was trying to just point you to how to do it versus doing it for you. TITHW_TotalMonth = VAR __MaxYear = MAX('Years'[Year]) VAR __MaxMonth = MAX('Months'[MonthSort]) VAR __TmpTable = CALCULATETABLE('TheHardWay',ALL('Years'[Year]),All('Months'[Month])) RETURN SUMX(FILTER(__TmpTable,[Year]=__MaxYear && [MonthSort] = __MaxMonth),[Value]) TITHW_TotalLastMonth = VAR __MaxYear = MAX('Years'[Year]) VAR __MaxMonth = MAX('Months'[MonthSort]) VAR __TmpTable = CALCULATETABLE('TheHardWay',ALL('Years'[Year]),All('Months'[Month])) RETURN SUMX(FILTER(__TmpTable,[Year]=__MaxYear-1 && [MonthSort] = __MaxMonth-1),[Value]) TITHW_%ChangeMoM = VAR __MaxYear = MAX('Years'[Year]) VAR __MaxMonth = MAX('Months'[MonthSort]) VAR __TmpTable = CALCULATETABLE('TheHardWay',ALL('Years'[Year]),All('Months'[Month])) VAR __currentMonth = SUMX(FILTER(__TmpTable,[Year]=__MaxYear && [MonthSort] = __MaxMonth),[Value]) VAR __previousMonth = SUMX(FILTER(__TmpTable,[Year]=__MaxYear - 1 && [MonthSort] = __MaxMonth-1),[Value]) RETURN DIVIDE(__currentMonth - __previousMonth,__previousMonth,0) Something like that, might have to take into account January and December boundary case.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.