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
ebeauchamp
Helper I
Helper I

Finding monthly $ variance on TotalMTD: full months vs. current month, in a same table

Hi,
In this topic:
https://carldesouza.com/total-month-to-date-totalmtd-totalqtd-totalytd-datesmtd-power-bi/

There is a description of how this measure:

MTD = TOTALMTD(SUM(Orders[Amount]), Dates[Date], FILTER(Dates, Dates[Date] < TODAY()))

Can be used to have the previous months showing the full amounts, and the current month showing the MTD up to yesterday, as per this screenshot:

MTD.jpg


The challenge I have is to calculate the proper monthly $ variances from such a table. For all the complete months, this is basically using [MTD]-[PMTD]. However, for the current month, the calculation should compare the MTD up to yesterday, with the PMTD of the same day, a month ago, to see how much we increased vs. the same day last month, eg on the same period.  And the results should all be in the same column, in order to create the proper visuals.

Tried many measures to achieve this but having no luck so far. Any ideas?

Thanks in advance for your help!
Erik 

 
1 ACCEPTED SOLUTION
ebeauchamp
Helper I
Helper I

Thanks for the suggestions. After reviewing them and reading many more posts, the following solution worked:
Step 1. In the Transactions table, added this calculated column:

IsCurrentMonth =
IF (
YEAR(Transactions[Date]) = YEAR(TODAY())
&& MONTH(Transactions[Date]) = MONTH(TODAY()),
"Yes",
"No"
)

Step 2. Created a measure using the "Values" function, which uses the step 1 column as a condition, in order to "assign" one of the two measures: MoM for completed months, and MTD for the current month.

VarianceMoM&MTD = IF(VALUES(Transactions[IsCurrentMonth])="No",[Amounts$MoM$],[MTDVar$])

Result: this new measure uses the Mom measure for past months, and the MTD measure for the current one. Glad to have discovered this "Values" function since it allows to build a measure tapping into the table columns, without needing to do a calculation first (sum etc). 

Var.jpg


View solution in original post

3 REPLIES 3
ebeauchamp
Helper I
Helper I

Thanks for the suggestions. After reviewing them and reading many more posts, the following solution worked:
Step 1. In the Transactions table, added this calculated column:

IsCurrentMonth =
IF (
YEAR(Transactions[Date]) = YEAR(TODAY())
&& MONTH(Transactions[Date]) = MONTH(TODAY()),
"Yes",
"No"
)

Step 2. Created a measure using the "Values" function, which uses the step 1 column as a condition, in order to "assign" one of the two measures: MoM for completed months, and MTD for the current month.

VarianceMoM&MTD = IF(VALUES(Transactions[IsCurrentMonth])="No",[Amounts$MoM$],[MTDVar$])

Result: this new measure uses the Mom measure for past months, and the MTD measure for the current one. Glad to have discovered this "Values" function since it allows to build a measure tapping into the table columns, without needing to do a calculation first (sum etc). 

Var.jpg


Anonymous
Not applicable

 

 

MTD := 
	calculate(
		[Total Amount],
		Dates[Date] < TODAY(),
		DATESMTD( Dates[Date] )
	)

PYMTD :=
var __effectiveDates =
	CALCULATETABLE(
		VALUES( Dates[Date] ),
		KEEPFILTERS( Dates[Date] < TODAY() )
	)
return
	calculate(
		[MTD],
		SAMEPERIODLASTYEAR( __effectiveDates )
	)

 

 

Best

D

Greg_Deckler
Super User
Super User

Time intelligence functions are really just syntax sugar for FILTER. If you want explicit control over your date filters, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

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...

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.

Top Solution Authors