Forum Discussion
Anonymous
3 years agoNot applicable
DAX variable how to
I have the following datasets: 1) Calendar 2) Actual: captures actual monthly sales Month Value Jan 1000 Feb 1200 Mar 800 etc 3) Forecast: captures forecast sales f...
v-yanjiang-msft
3 years agoCommunity Support
Hi Anonymous ,
According to your description, here's my solution.
1. Create a Month table. Sort Month column by MonthNo column.
2.Create a measure.
Sales =
IF (
MAX ( 'Month'[MonthNo] ) <= SELECTEDVALUE ( 'Date'[Month] ),
MAXX (
FILTER ( Actual, MONTH ( 'Actual'[Date] ) = MAX ( 'Month'[MonthNo] ) ),
'Actual'[YTD]
),
IF (
MAX ( 'Month'[Month] ) <> "Total Year",
MAXX (
FILTER (
'Forecast',
'Forecast'[ActMth] = SELECTEDVALUE ( 'Date'[Month] )
&& MONTH ( 'Forecast'[Date] ) = MAX ( 'Month'[MonthNo] )
),
'Forecast'[Value]
),
SUMX (
FILTER ( Actual, MONTH ( 'Actual'[Date] ) <= SELECTEDVALUE ( 'Date'[Month] ) ),
'Actual'[YTD]
)
+ SUMX (
FILTER (
'Forecast',
'Forecast'[ActMth] = SELECTEDVALUE ( 'Date'[Month] )
&& MONTH ( 'Forecast'[Date] ) > SELECTEDVALUE ( 'Date'[Month] )
),
'Forecast'[Value]
)
)
)
Put Month column from Month table in Matrix column and the measure in values, get the result:
I attach my sample below for your reference.
Best regards,
Community Support Team_yanjiang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.