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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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