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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
prathameshw
Regular Visitor

How to not show legend values for 0 value categories

I have to create a dashboard where I my x-axis has all years and y-axis has all the categories. (see below). The categories will not always have values and will be 0. When i plot the legend, it shows all the values even if 0 or not 0. How can I only show non-zero categories in the legend and hide 0 categories?

 

prathameshw_0-1718657233308.png

 

My table looks something like this

 

prathameshw_1-1718657440011.png

 

 

Any help will be appreciated. TIA

 

 

1 ACCEPTED SOLUTION
Moetazzahran
Resolver II
Resolver II

Hello, 
You can use a measure which has the following formula.

Legendexclude = Switch(True(),MAX('Table'[Value])<>0,1,0)
Moetazzahran_2-1718670174286.png

 


 This is how the base table I used looks like.

Moetazzahran_1-1718670113973.png

Please let me know if this works properly in your case. If this solves your requirement, please accept it as a solution. You kudo is much appreciated.

You can use this post as a reference as well. 
Solved: Re: Legend - Too many Values -- How to hide legend... - Microsoft Fabric Community

View solution in original post

2 REPLIES 2
Moetazzahran
Resolver II
Resolver II

Hello, 
You can use a measure which has the following formula.

Legendexclude = Switch(True(),MAX('Table'[Value])<>0,1,0)
Moetazzahran_2-1718670174286.png

 


 This is how the base table I used looks like.

Moetazzahran_1-1718670113973.png

Please let me know if this works properly in your case. If this solves your requirement, please accept it as a solution. You kudo is much appreciated.

You can use this post as a reference as well. 
Solved: Re: Legend - Too many Values -- How to hide legend... - Microsoft Fabric Community

Thanks. I had to reorganize the table (unpivot) but this is a great workaround.

 

I have an issue here. I dont see negative values, I only see positive. Why is that?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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