Can legends in PowerBI Pie Chart be hidden if value is zero? - powerbi

In a Power BI Pie Chart total 8 legends(category) are there and count is distributed by category as shown in 1st pic. When I select Only June 2020 (2nd pic), there is data only for 5 category and accordingly it is distributed in Pie Chart. In both images, there are 8 legends are shown in right side.
Is it possible to hide the legend if there is no value for that legend. for example : in 2nd image, possible to hide remaining 3 legends and only shown legends for which data is there?

First create a measure using the following dax function:
Cross Filter = INT( NOT( ISEMPTY( FAC_TABLE ) ) )
Select your visualization, open the filter panel and drag the measure in the Filter on this visual option. Finally select the option equal to 1. The following image is in spanish but you will get the idea.
Hope it helps.

As suggested by Agustin I created below measure:
FilterMeasure = INT(NOT(ISEMPTY(Filter(TableName,TableName[Category]=TableName[Category]))))
and below is filter pan:

Related

Power BI: How to conditionally format a row of a table in Power BI DAX

I am new to DAX and I need help to colour the background of a row in table using DAX.
Name
text
Book
Ora
Pencil
hjui
I want to colour the entire row of table with Name = Book in ORange
Can someone help me
Yes, it is possible using conditional formatting.
In the Fields pane, right click your table and create the following measure:
Background color = IF(MAX('Table'[Name]) = "Book", "Orange", BLANK())
Then select the table visual and in Visualizations pane, right click each of the columns and select Conditional formatting -> Background color:
In Format by select Field value and select the above created measure in Based on field:
After you do that for each column shown, the result will be as follows:

Filter top 25 entries which changes the bar & line Chart

I have created a Dashboard where I have a list of 100 entries of different frim names, I have created a rank measure and have add it to the filters to get the top 25 firms in terms of their sales and I have a bar & line chart at the bottom.
My problem is that my table data with the firm names & their other details is getting filtered but my Bar & line chart shows the data for the entire 100 entries its not getting filtered as per my top 25 firms.
I tried using the rank measure in its filters but still not working, but if we select an induvial firm or multiple firms it changes.
Can some please help me here, I want my charts to auto filter the moment I select top 25 button along with my table
If you have a Rank measure created, you can use Filter Type "Top N" by Rank value.
To test the same:
Select the visual created.
on the Filters pane on the right, expand the firm filter.
Under filter type, select the option "Top N" and value as Rank.
Apply filter

Show Grand Total label on a stacked column chart

I have a Line and Stacked Column chart to which I want to add a "Grand Total" label at the top as the sum of the components in the stack.
I'd like to create a measure that sums the values in the Total column (in the data shown at the bottom of the screenshot) as "Grand Total" so that it can be applied to the chart. I've had no luck using the SUM and SUMMARIZE functions so far.
Suggestions to achieve this are much appreciated. Thanks in advance.
There's not a built-in way to do this at the moment but there are workarounds.
The idea is to use the combo Line and Stacked Column Chart and put the total as the line value and then hide the line.
Radacad explains it in more detail here:
Showing the Total Value in Stacked Column Chart in Power BI
To get a grand total across all of the divisions, you can adjust your filter context as follows:
GrandTotal =
CALCULATE ( SUM ( CapExOpExNew[Total] ), ALL ( CapExOpExNew[Funding Division] ) )

How to filter a Pie chart by selection in table

Please consider this scenario:
I have a table in Power-BI that's like this:
Country Total Sales
-----------------------------
USA 2000
Canada 1400
Spain 3200
And I want to have a Pie chart in page that if user clicks on every rows, The pie shows sales type for that Country. For Example:
How can I connect these to visuals together?
Thanks
If the two visuals shows data from the same data source, then they will be "connected" by default, i.e. when the user clicks on a row in the table, the pie chart will show only the data from the selected country, and if the user clicks on a sector from the chart, the table will show only the amounts for this category.
If you have a table in your data source like this:
Then add a table in the report with columns Country and Sales like this:
By default amounts will be aggregated as sum, so the table will show sum of Sales per Country. You can change the default summarization of the currently selected field in Modeling tab:
Add a pie chart with Category field in the legend and Sales field for value. Change the value to be shown as percentage from the grand total like this:
Adding Sales field as tooltip will also show the amount when pointing to a sector:
Now when you click on a row in the table, the pie chart will show only the relevant data:
For more information take a look at Change how visuals interact in a Power BI report and Filters and highlighting in Power BI reports articles.
Well, it does not work if the pie chart is top-N pie chart. I open a new issue to the Power BI community to fix it. Here is a description of the issue: Basically, I have a top-N pie chart created for states. But, when I select a city in a table and the city is not in one of those states, the pie chart is not updated to show the state of the selected city. Instead, it remains to show those top-N states with 0% in every slices. This is wrong. It should show the top-N states of the "selected" cities.

How to add Filter to Slicer to display the calculated Measure based on selection using Power BI

I am totally new to Power BI and struggling with Slicer. I have the below requirement:
I have 4 columns Starting From, Destination, Distance KM. For this, I need to add a slicer. If the user clicks on Distance KM, then the chart has to be updated with Distance KM values. Now here comes the trick. I also want to display a column Distance in Miles based on the Distance KM calculation(the KM has to be displayed in Miles). So, whenever user clicks on Distance KM(in slicer), it should show the chart with KM data, if the user clicks on Miles(in slicer), then the chart should be populated with Miles information. I need to do this using slicer in power bi. Trying to achieve this since a while but couldn't get through it.
Please help me out
You only list three columns after stating your data has four, but I believe this should work:
You need to create a new table for the slicer. Within the Home tab select "Enter Data". Enter the values you want to be able to select from (I named the table DistanceSlicer). Load that table and create a slicer with it.
Now you can create a new measure based on this slicer selection. Within the Modeling tab select "New Measure".
SelectedMeasure =
IF (
VALUES ( DistanceSlicer[Measure] ) = "Kilometers",
SUM ( Table1[Distance KM] ),
SUM ( Table1[Distance Miles] )
)
Now use this measure in your table/chart and it should update based on your slicer selection.