Forum Discussion
100% Stacked Bar Chart with what-if parameter
- 4 years ago
Hi Anonymous ,
According to your description, here's my solution.
1.Create a section table containing the four sections.
2.Create a measure.
Measure = VAR _P = SELECTEDVALUE ( Parameter[Parameter] ) RETURN SWITCH ( MAX ( 'Section Table'[Section] ), "below 50%", CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), FILTER ( ALL ( 'Table' ), SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ), 'Table'[Amount] ) < 0.5 * _P ) ), "between 50 to 80%", CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), FILTER ( ALL ( 'Table' ), SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ), 'Table'[Amount] ) >= 0.5 * _P && SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ), 'Table'[Amount] ) < 0.8 * _P ) ), "between 80 to 100%", CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), FILTER ( ALL ( 'Table' ), SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ), 'Table'[Amount] ) >= 0.8 * _P && SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ), 'Table'[Amount] ) <= _P ) ), "over 100%", CALCULATE ( DISTINCTCOUNT ( 'Table'[ID] ), FILTER ( ALL ( 'Table' ), SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ), 'Table'[Amount] ) > _P ) ) )3.In the 100% Stacked Bar Chart, put the Section column in the Legend, the measure in the Values, get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
According to your description, here's my solution.
1.Create a section table containing the four sections.
2.Create a measure.
Measure =
VAR _P =
SELECTEDVALUE ( Parameter[Parameter] )
RETURN
SWITCH (
MAX ( 'Section Table'[Section] ),
"below 50%",
CALCULATE (
DISTINCTCOUNT ( 'Table'[ID] ),
FILTER (
ALL ( 'Table' ),
SUMX (
FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
'Table'[Amount]
) < 0.5 * _P
)
),
"between 50 to 80%",
CALCULATE (
DISTINCTCOUNT ( 'Table'[ID] ),
FILTER (
ALL ( 'Table' ),
SUMX (
FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
'Table'[Amount]
) >= 0.5 * _P
&& SUMX (
FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
'Table'[Amount]
) < 0.8 * _P
)
),
"between 80 to 100%",
CALCULATE (
DISTINCTCOUNT ( 'Table'[ID] ),
FILTER (
ALL ( 'Table' ),
SUMX (
FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
'Table'[Amount]
) >= 0.8 * _P
&& SUMX (
FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
'Table'[Amount]
) <= _P
)
),
"over 100%",
CALCULATE (
DISTINCTCOUNT ( 'Table'[ID] ),
FILTER (
ALL ( 'Table' ),
SUMX (
FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
'Table'[Amount]
) > _P
)
)
)
3.In the 100% Stacked Bar Chart, put the Section column in the Legend, the measure in the Values, get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.