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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
WLFRD
Helper III
Helper III

Sum part of bar chart as percentage of total

Hello,

 

as part of a project I would like to sum a part of a bar chart in Power BI as a percentage of total amount. 

 

This is my data set:

 

Enter_dateStock_date
07-Mar-2207-Mar-22
07-Mar-2207-Mar-22
07-Mar-2207-Mar-22
07-Mar-2207-Mar-22
07-Mar-2207-Mar-22
07-Mar-2207-Mar-22
07-Mar-2207-Mar-22
04-Mar-2204-Mar-22
04-Mar-2204-Mar-22
04-Mar-2207-Mar-22
04-Mar-2204-Mar-22
04-Mar-2207-Mar-22
04-Mar-2204-Mar-22
04-Mar-2207-Mar-22
04-Mar-2204-Mar-22
03-Mar-2207-Mar-22
03-Mar-2207-Mar-22
03-Mar-2207-Mar-22
03-Mar-2207-Mar-22
03-Mar-2207-Mar-22
03-Mar-2207-Mar-22
03-Mar-2204-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2204-Mar-22
03-Mar-2203-Mar-22
03-Mar-2207-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2207-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2203-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2207-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2203-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2203-Mar-22
03-Mar-2204-Mar-22
03-Mar-2204-Mar-22
02-Mar-2203-Mar-22
02-Mar-2204-Mar-22
02-Mar-2203-Mar-22
02-Mar-2203-Mar-22
02-Mar-2202-Mar-22
02-Mar-2204-Mar-22
02-Mar-2204-Mar-22
02-Mar-2204-Mar-22
02-Mar-2202-Mar-22
02-Mar-2202-Mar-22
02-Mar-2207-Mar-22
02-Mar-2202-Mar-22
02-Mar-2203-Mar-22
02-Mar-2203-Mar-22
02-Mar-2203-Mar-22
02-Mar-2202-Mar-22

 

Capture.JPG

 

I would like to calculate the date difference in days and show the result in a bar chart. Result would look something like this. 

 

Capture.JPG

(This is an example, not related to the data given at the beginning of this message)

 

First I add a column to calculate the day difference between the order date and stock date. Next, I have added a conditional column in the query editor. Based on the outcome of the difference between the two dates, these days are added up and put into a bar chart per category (1, 2, 3, 4.... days).

I don't know if this is the best way to calculate the percentage. If not, please tell me how to do this. 

 

I would like to calculate the sum of the green bar charts as a percentage of the total. How can I do that?

 

Thanks in advance.

 

Regards,

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@WLFRD , Create a new column

new column =

var _diff = datediff([enter date],[stock date],day)

return

Switch(True() ,

_diff =0, "Resolved on same day" ,

// Add other options

"Other" //default

)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@WLFRD , Create a new column

new column =

var _diff = datediff([enter date],[stock date],day)

return

Switch(True() ,

_diff =0, "Resolved on same day" ,

// Add other options

"Other" //default

)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.