Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Rabi
Resolver I
Resolver I

Formatting Negative and Positive values in a Stacked Baar Chart

Hi Everyone, 

 

Please Help me with this,

I have visualized sales in a stacked bar chart, based on the target sales I have calculated Excess/Shortfall sales values. so negative value is shortfall and positive value is excess. I want to format the negative and positive values with different colors.

Rabi_0-1694388431519.png

 

Shortfall and Excess is coming from same column so cant be given different colours from formatting pane. I also tried separating excess and shortfall sales into two different column, this way i can assign different colours, but when multiple dates and stores selected a single date has bot excess and shortfall sales which is not right.

 

Please help me with this.

 

Regards,

Rabi

 

11 REPLIES 11
parry2k
Super User
Super User

@Rabi I will let someone else work on it. Not super happy with the reply. Good luck!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Rabi You are making it hard on us, where are Target Sales, Actual Sales columns? Are these measures? It shouldn't be that tough to explain. At this point, I would recommend putting a pbix file with sample data and any calculation you are doing and sharing that pbix file. I'm not going to do the work of preparing the raw data for you.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Sorry @parry2k , EVERYTHING IS A COLUMN

Rabi_0-1694396099114.png

 

Rabi
Resolver I
Resolver I

Hi @parry2kk and Everyone Below is the sample data and Dax:

Rabi_0-1694394992953.png

Dax for Excess/Shortfall= Target sales-Actual sales

Sales Shortfall = IF ([Shortfall/Excess]<0, [Shortfall/Excess], 0)
Sales Exces= IF ([Shortfall/Excess]>0, [Shortfall/Excess], 0)
parry2k
Super User
Super User

@CoreyP I wouldn't go that route for many reasons, instead will calculate measures for excess/shortfall and then use that in the visual and that's why I'm asking what the raw data looks like. One solution doesn't fit all until you understand the data structure and I don't like to provide the solution if I'm fully clear about the underline data.

 

The reason wouldn't add new columns and unpivot, it will be expensive, impact on performance, and consume more memory because calculated columns need to be stored in memory. If it is a large table it will take way too long to refresh and end of the day you still have to create the measures to visualize the data. Anyhow, that's my approach and thinking. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@CoreyP Unfortunaltey I don't think it is the right approach in this case since Excess and Shortfall are getting calculated. I could be completely wrong.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k , wouldn't the calculated values in the applied steps prior to the unpivot remain the same after the unpivot? I mean the crux of the issue is that you cannot conditionally format with two measures; it needs the legend field populated. What if he creates a legend dimension, almost like the table a field paramter creates?

CoreyP
Solution Sage
Solution Sage

What if you were to then unpivot the table so it would be in the format of:

Date | Type | Amount
27/08/2023 | Actual Sales | $x
27/08/2023 | Target Sales | $x
27/08/2023 | Excess Sales | $x
27/08/2023 | Shortfall Sales | $x

That way you just have one measure, SUM( [Amount] ), and you can use the Type field in the Legend.

parry2k
Super User
Super User

@Rabi you can always generate a sample data and share it. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Rabi can you share how your sample data looks like and what measures you are using to calculate short/gain?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k , 

 

To calculate the excess and shortfall, I first Subtracted Actual sales with target. Then I separated values >0 into a new column Excess and i separated values <0 in a new column shortfall. unfortunately i wount be able to share the data as it is very sensitive.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.