Forum Discussion
Converting YTD to MTD based on two variables
Hello,
I need to extract the monthly movement from the YTD based on two variables - the entity and LOB (line of business). The values are not available on a montly basis.
Below is a sample of the data table
I tried to use this from another solution but it doesnt work?
Monthly Amount New =
VAR _PDATE =
CALCULATE(
MAX('dataset'[Date]),
CALCULATETABLE(
ALLSELECTED('dataset'),
'dataset'[Product]=('dataset'[Product]),
'dataset'[Entity] = ('dataset'[Entity]),
'dataset'[Date]< EARLIER('dataset'[Date])
)
)
VAR _PYTD =
CALCULATE( MAX('dataset'[YTD Value]),
CALCULATETABLE(
ALLSELECTED('dataset'),
'dataset'[Product]=EARLIER('dataset'[Product]),
'dataset'[Entity] = EARLIER('dataset'[Entity]),
'dataset'[Date] = _PDATE
)
)
VAR YR =YEAR(_PDATE)
VAR CYR =YEAR('dataset'[Date])
RETURN
IF(
YR < CYR,
[YTD Value],
[YTD Value] - _PYTD
) Thanks for your help
Kerry
3 Replies
- amitchandak
Super User
Anonymous , Try a new column like
Monthly Amount New =
VAR _max = maxx(Filter('dataset'[Product]=('dataset'[Product]) && 'dataset'[Entity] = ('dataset'[Entity]) && 'dataset'[Date]< EARLIER('dataset'[Date])),'dataset'[Date])
return
[Value] - maxx(Filter('dataset'[Product]=('dataset'[Product]) && 'dataset'[Entity] = ('dataset'[Entity]) && 'dataset'[Date] =_max),'dataset'[Value]) - AnonymousNot applicable
- v-angzheng-msft
Community Support
Hi, Anonymous
Could you please consider sharing more details about it and posting expected result so it is clear on what needs to be implemented? And It would be great if there is a sample file without any sesentive information here.
It makes it easier to give you a solution.
- Sample (dummy dataset) data as text, use the table tool in the editing bar
- Expected output from sample data
- Explanation in words of how to get from 1. to 2.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.