March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi all
I want to calcuate the last 12 month Moving Annual totals, which i am using the following which is working. What i am struggling with is a measure or comparrision against the same period last year. ie 2019 against 2018. Do i do two measures?? i am having a brain blank!!!! Ideally having a MAT figure per month for 2018, 2019 etc etc
Solved! Go to Solution.
For that one you can put in the IF ( ISBLANK () from your original:
Mat Volumn 12 =
VAR _DateEnd =
LASTDATE ( VRS[VRS Date] )
RETURN
IF ( ISBLANK ( [Net Sales] ), BLANK(),
CALCULATE (
[Net Sales],
ALL ( VRS ),
DATESINPERIOD ( VRS[VRS Date], _DateEnd, -12, MONTH )
)
)
Hello @tmears
First, I would write a measure just for Net Sales so you have it to use in other measures.
Net Sales = SUM ( VRS[NetSales] )
Then the rolling 12 can be simplified using DATESINPERIOD
Mat Volumn 12 =
VAR _DateEnd =
LASTDATE ( VRS[VRS Date] )
RETURN
CALCULATE (
[Net Sales],
ALL ( VRS ),
DATESINPERIOD ( VRS[VRS Date], _DateEnd, -12, MONTH )
)
And the prior year can use SAMEPERIODLASTYEAR
Mat Volumn PY =
CALCULATE (
[Mat Volumn 12],
ALL ( VRS ),
SAMEPERIODLASTYEAR ( VRS[VRS Date] )
)
Perfect thanks @jdbuchanan71 the only thing i have as a problem now is that the measaure is pulling in a figure for the next couple of month ie nov and dec, (the data is unto end of Oct) can i remove these??
For that one you can put in the IF ( ISBLANK () from your original:
Mat Volumn 12 =
VAR _DateEnd =
LASTDATE ( VRS[VRS Date] )
RETURN
IF ( ISBLANK ( [Net Sales] ), BLANK(),
CALCULATE (
[Net Sales],
ALL ( VRS ),
DATESINPERIOD ( VRS[VRS Date], _DateEnd, -12, MONTH )
)
)
@jdbuchanan71you are a star, thank you so much!! Not sure if i can push my luck, i also need to do this calculation based upon the customer called buying group. but obviously if i bring in the 'buying group' it returns a total sum. the customer called buying group. but obviously if i bring in the 'buying group' it returns a total sum.
Change the ALL ( VRS ) to ALL ( VRS[VRS Date] ) which should repect the other filters.
thank you so much..... you hero status in my office at the moment!!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
106 | |
98 | |
65 | |
54 |