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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Frozensparrow
Frequent Visitor

Showing total count Value in Bar Chart

Hi,

 

I got stuck, looking thru all the chart solution in this forum... still doesn't feel any enlightenment. I am trying to get the total count to appear on my bar chart. I have

- x-axis with the owner name

- y-axis with count of Overdue number

 

How do I get the total of overdue ( which the count should be total 6) onto that bar chart? Hope to get some pointer from the expert from this forum. Thanks a ton.

 

Frozensparrow_0-1678090504122.png

 

2 ACCEPTED SOLUTIONS
v-tangjie-msft
Community Support
Community Support

Hi @Frozensparrow ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1678154705252.png

(2) Click "Transform Data" to enter the Power Query Editor, click "Advanced Editor" to copy and paste the following code, you can check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJUitXBznLCwnKGsGIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Owner = _t, OverDue = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Owner", type text}, {"OverDue", Int64.Type}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Added Custom" = Table.AddColumn(#"Transposed Table", "Custom", each "Total"),
    #"Transposed Table1" = Table.Transpose(#"Added Custom"),
    #"Replaced Value" = Table.ReplaceValue(#"Transposed Table1","Total","",Replacer.ReplaceValue,{"Column2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value",{{"Column2", type number}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Column1", "Owner"}, {"Column2", "OverDue"}})
in
    #"Renamed Columns"

(3)Click "Close and Apply" and we can create two calculated columns and two measures.

count = COUNTROWS(FILTER('Table','Table'[Owner]=EARLIER('Table'[Owner])))
total = COUNTROWS('Table')-1
Measure = IF(MAX('Table'[OverDue])=BLANK(),MAX('Table'[total]),MAX('Table'[count]))
color = IF(MAX('Table'[Owner])="Total",1,0)

(4)Set the conditional formatting as shown in the following figure.

vtangjiemsft_2-1678155008655.pngvtangjiemsft_3-1678155053843.png

(5)Then the result is as follows.

vtangjiemsft_4-1678155096277.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

Frozensparrow
Frequent Visitor

Thanks Neeko, you sample pbix allow me to understand better, and give me the idea on the approach. Thank you so much. 🙂

View solution in original post

2 REPLIES 2
Frozensparrow
Frequent Visitor

Thanks Neeko, you sample pbix allow me to understand better, and give me the idea on the approach. Thank you so much. 🙂

v-tangjie-msft
Community Support
Community Support

Hi @Frozensparrow ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1678154705252.png

(2) Click "Transform Data" to enter the Power Query Editor, click "Advanced Editor" to copy and paste the following code, you can check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJUitXBznLCwnKGsGIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Owner = _t, OverDue = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Owner", type text}, {"OverDue", Int64.Type}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Added Custom" = Table.AddColumn(#"Transposed Table", "Custom", each "Total"),
    #"Transposed Table1" = Table.Transpose(#"Added Custom"),
    #"Replaced Value" = Table.ReplaceValue(#"Transposed Table1","Total","",Replacer.ReplaceValue,{"Column2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value",{{"Column2", type number}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Column1", "Owner"}, {"Column2", "OverDue"}})
in
    #"Renamed Columns"

(3)Click "Close and Apply" and we can create two calculated columns and two measures.

count = COUNTROWS(FILTER('Table','Table'[Owner]=EARLIER('Table'[Owner])))
total = COUNTROWS('Table')-1
Measure = IF(MAX('Table'[OverDue])=BLANK(),MAX('Table'[total]),MAX('Table'[count]))
color = IF(MAX('Table'[Owner])="Total",1,0)

(4)Set the conditional formatting as shown in the following figure.

vtangjiemsft_2-1678155008655.pngvtangjiemsft_3-1678155053843.png

(5)Then the result is as follows.

vtangjiemsft_4-1678155096277.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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