Hi,
I have two tables which contain targets for different business areas (HardwareTargets & SoftwareTargets). They differ in content and shape and cannot be appended together. What is common between the two is that they contain a [Year] column (eg 2018, 2019) and a [BudgetType column (eg Budget, 3+9 Forecast, 6+6 Forecast, 9+3 Forecast).
To allow the user to filter both of the tables by BudgetType, I created a table in Dax, containing the unique values of [BudgetType] from both tables:
EVALUATE
(
DISTINCT (
UNION (
SUMMARIZE ( 'HardwareTargets ', 'HardwareTargets '[BudgetType] ),
SUMMARIZE ( ‘SoftwareTargets’, ‘SoftwareTargets’[BudgetType] )
)
)
)
Returns:
Budget
Forecast 3+9
Forecast 6+6
Forecast 9+3
I then relate this new lookup table to my two budget tables and the user can happily select one of the four values in their slicer and it filters both budget tables.
The problem is that when the user slices on Year, say 2019, we still get all the values, whereas only the below are actually present in the tables for 2019:
Budget
Forecast 3+9
I therefore need to filter my DAX table so that it takes into consideration the currently selected Year value. I tried to use SUMMARISECOLUMNS with a filter of selected value, but it does not return any data?
EVALUATE
VAR __YEAR =
SELECTEDVALUE ( Dates[Year] )
RETURN
(
DISTINCT (
UNION (
SUMMARIZECOLUMNS (
‘HardwareTargets’[BudgetType],
FILTER ( ‘Vehicle Targets’, __YEAR )
),
SUMMARIZECOLUMNS (
'SoftwareTargets '[TargetType],
FILTER ( ‘Vehicle Targets’, __YEAR )
)
)
)
)
Yet, if I hard code my variable __YEAR to 2019 it does work as I want?
Am I going about this the wrong way?
Many thanks in advance for any help - first time using the forum here!
Mark
PS: How do I retain the formatting of the DAX code in my posts?