Forum Discussion
Stacked Bar Chart Conditional Formatting
Background:
desired format
 IF([STR_CYCLONEFILLVOL] >= [Cyclone Vol LCL 1StdD], [Cyclone Vol LCL 1StdD], SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
[STR_CYCLONEFILLVOL] = Chart with blue bars.
[Cyclone Vol Lower] = Chart with purple bars.
Note: I have thought about "hard coding" the UCL, LCL etc as a new column in the table and doing my calcs that way, however, ideally I would like for the measures to be calculated coninually so that the averages/LCL/UCL/Std Dev can be calculated over the entire dataset as the process matures.
Many thanks,
Rob
- Anonymous1 year ago
Hi Rob123,
Thank you for reaching out to the Microsoft Fabric Forum Community.
Also, thanks to HarishKM for the prompt and helpful response.
Try using fallowing dax measures :
Cyclone Vol Lower =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR lcl = [Cyclone Vol LCL 1StdD]
RETURN
IF(vol < lcl, vol, lcl)
Cyclone Vol Middle =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR lcl = [Cyclone Vol LCL 1StdD]
VAR ucl = [Cyclone Vol UCL 1StdD]
RETURN
IF(vol > lcl && vol < ucl, vol - lcl,
IF(vol >= ucl, ucl - lcl, 0))
Cyclone Vol Upper =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR ucl = [Cyclone Vol UCL 1StdD]
RETURN
IF(vol > ucl, vol - ucl, 0)
Axis is SM4_BUCKETLIST[L_BUCKETNR] and in values use 3 measures.If the issue still persists, please feel free to share more details so we can further investigate and help resolve it.
If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.
Thank you & Regards,
Prasanna kumar Hello!
Thank you both for your suggestions.
Initially this did not work, which led me to look further back at my other calculations.
What I realised was my average calculations of [STR_CYCLONEFILLVOL] and my Standard Deviation calculation were getting calculated on a row level rather than considering the entire data set.Original measures:
[Avg Cyclone Vol] = AVERAGE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])[Std Dev Cyclone Vol] = STDEV.P(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
New Measures - I changed these to the following:Avg Cyclone Vol = AVERAGEX(ALLSELECTED(SM4_BUCKETLIST),SM4_BUCKETLIST[STR_CYCLONEFILLVOL])Std Dev Cyclone Vol = STDEVX.P(ALLSELECTED(SM4_BUCKETLIST),SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
Once I changed these, things Prasannag your solution worked!
Prasannag your solution:
Cyclone Vol Lower =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR lcl = [Cyclone Vol LCL 1StdD]
RETURN
IF(vol < lcl, vol, lcl)
Prasannag - I noted your use of SELECTEDVALUE(), so I thought I would try this with my original measure.My updated original measure:
Cyclone Vol Lower =
IF(SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL]) >= [Cyclone Vol LCL 1StdD], [Cyclone Vol LCL 1StdD], SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL]))
And this worked too!!
HarishKM I also tried your solution and also tried a combination of the SELECTEDVALUE() but unfortunately I could not get this solution to work. However, I am sure the error is somewhere on my part as I am still learning.
However I have a solution which is all that matters. Thank you both again for your help.
Regards,
Rob
4 Replies
- Rob123Frequent Visitor
Hello Harish,
I have tried this and unfortunately the result is the same. I get the same values.
Any other ideas?
Many thanks,
- AnonymousNot applicable
Hi Rob123,
Thank you for reaching out to the Microsoft Fabric Forum Community.
Also, thanks to HarishKM for the prompt and helpful response.
Try using fallowing dax measures :
Cyclone Vol Lower =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR lcl = [Cyclone Vol LCL 1StdD]
RETURN
IF(vol < lcl, vol, lcl)
Cyclone Vol Middle =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR lcl = [Cyclone Vol LCL 1StdD]
VAR ucl = [Cyclone Vol UCL 1StdD]
RETURN
IF(vol > lcl && vol < ucl, vol - lcl,
IF(vol >= ucl, ucl - lcl, 0))
Cyclone Vol Upper =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR ucl = [Cyclone Vol UCL 1StdD]
RETURN
IF(vol > ucl, vol - ucl, 0)
Axis is SM4_BUCKETLIST[L_BUCKETNR] and in values use 3 measures.If the issue still persists, please feel free to share more details so we can further investigate and help resolve it.
If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.
Thank you & Regards,
Prasanna kumar - Rob123Frequent Visitor
Hello!
Thank you both for your suggestions.
Initially this did not work, which led me to look further back at my other calculations.
What I realised was my average calculations of [STR_CYCLONEFILLVOL] and my Standard Deviation calculation were getting calculated on a row level rather than considering the entire data set.Original measures:
[Avg Cyclone Vol] = AVERAGE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])[Std Dev Cyclone Vol] = STDEV.P(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
New Measures - I changed these to the following:Avg Cyclone Vol = AVERAGEX(ALLSELECTED(SM4_BUCKETLIST),SM4_BUCKETLIST[STR_CYCLONEFILLVOL])Std Dev Cyclone Vol = STDEVX.P(ALLSELECTED(SM4_BUCKETLIST),SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
Once I changed these, things Prasannag your solution worked!
Prasannag your solution:
Cyclone Vol Lower =
VAR vol = SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL])
VAR lcl = [Cyclone Vol LCL 1StdD]
RETURN
IF(vol < lcl, vol, lcl)
Prasannag - I noted your use of SELECTEDVALUE(), so I thought I would try this with my original measure.My updated original measure:
Cyclone Vol Lower =
IF(SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL]) >= [Cyclone Vol LCL 1StdD], [Cyclone Vol LCL 1StdD], SELECTEDVALUE(SM4_BUCKETLIST[STR_CYCLONEFILLVOL]))
And this worked too!!
HarishKM I also tried your solution and also tried a combination of the SELECTEDVALUE() but unfortunately I could not get this solution to work. However, I am sure the error is somewhere on my part as I am still learning.
However I have a solution which is all that matters. Thank you both again for your help.
Regards,
Rob