Forum Discussion
Anonymous
3 years agoNot applicable
Total sales based on field parameter
Hi, Not sure if it is possible, but id like a column here which based on the parameter selected does a total of the matching grouping: So in the case below, now that product group is selected, I ...
- Anonymous3 years ago
Managed to solve it my self ๐
Solution pbixCreated the following measure:
Sales by selected parameter = VAR _SelectedParameter = SELECTEDVALUE ( Parameter[Parameter Order] ) VAR _CurrentDimension = SWITCH ( _SelectedParameter, 0, SELECTEDVALUE ( DimArticle[Product group] ), 1, SELECTEDVALUE ( DimArticle[sub product group] ), 2, SELECTEDVALUE ( 'Fact Sales'[Customer] ) ) VAR _TotalSales = SWITCH ( _SelectedParameter, 0, SUMX ( FILTER ( ALL('Fact Sales'), RELATED ( DimArticle[Product group] ) = _CurrentDimension ), 'Fact Sales'[Sales Value] ), 1, SUMX ( FILTER ( ALL('Fact Sales'), RELATED ( DimArticle[sub product group] ) = _CurrentDimension ), 'Fact Sales'[Sales Value] ), 2, SUMX ( FILTER ( ALL('Fact Sales'), 'Fact Sales'[Customer] = _CurrentDimension ), 'Fact Sales'[Sales Value] ) ) RETURN _TotalSales
Anonymous
3 years agoNot applicable
Managed to solve it my self ๐
Solution pbix
Created the following measure:
Sales by selected parameter =
VAR _SelectedParameter =
SELECTEDVALUE ( Parameter[Parameter Order] )
VAR _CurrentDimension =
SWITCH (
_SelectedParameter,
0, SELECTEDVALUE ( DimArticle[Product group] ),
1, SELECTEDVALUE ( DimArticle[sub product group] ),
2, SELECTEDVALUE ( 'Fact Sales'[Customer] )
)
VAR _TotalSales =
SWITCH (
_SelectedParameter,
0,
SUMX (
FILTER (
ALL('Fact Sales'),
RELATED ( DimArticle[Product group] ) = _CurrentDimension
),
'Fact Sales'[Sales Value]
),
1,
SUMX (
FILTER (
ALL('Fact Sales'),
RELATED ( DimArticle[sub product group] ) = _CurrentDimension
),
'Fact Sales'[Sales Value]
),
2,
SUMX (
FILTER (
ALL('Fact Sales'),
'Fact Sales'[Customer] = _CurrentDimension
),
'Fact Sales'[Sales Value]
)
)
RETURN
_TotalSales