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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
shere100
Helper II
Helper II

Power Bi Filters

Hi, quick question.

 

If there is no data in the result set currently, how do I a build a data set so if / when there is data in that criteria to include in the filter if not then display a 0?

 

I have clicked on advanced filtering, in here I can select if a criteria contains the value but if that valuee does not exist then to appear as zero or blank? In advance filtering there is an 'And' and 'Or' statement but not for a one off filter type that does not exist but if it did then to appear.

 

Please advise.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You're welcome. Thinking a bit more about this. The solution will work, but I don't think it's the most elegant way. 

You're talking about expected statuses that don't actually exist. But actually, you know what the statuses will be, right?

 

You can add another table, with the list of expected statuses.

Then create a Relationship between this table and your current table. That relationship will cause the existing table to be filtered by the new.

 

Create the following visual to show all statuses:

1.  Table visual with the Status from the new table, and the Count of Status measure.

2. Right-click the Status field, and click "Show items with no data". 

 

Each row in the table is a status - since the new table filters the existing, the existing table is limited to only the rows with that status.

View solution in original post

21 REPLIES 21
TeigeGao
Solution Sage
Solution Sage

Hi shere100,

According to your description, my understanding is that you want to display 0 or blank in visual when no data matches the filter.

In this scenario, we can use the count() function to do that, please refer to the following query:

Measure = var a = FILTER(Data,Data[Date] = DATE(2019,02,01))
return IF(COUNTROWS(a) = 0,BLANK(),CALCULATE(MAX(Data[Data]),a))

Best Regards,

Teige 

Hi, thanks for the query. This is what I am looking for. 

 

Please can you let me know how I execute this please? 


If the table is called 'Test' and the field is called 'Test Result' and the filter 'passed' did not exist, in this instance I would want the display to be '0'. Please can you construct the query for me? 

 

Would I have to create a measure query for each status if they do not exist and I would like a zero to appear for the field 'Test Result'?

Anonymous
Not applicable

@shere100 -

You could create a measure like this:

 

My Measure = 

var a = SUM('Test'[Test Result])

return IF(ISBLANK(a), 0, a)

 

What is does: loads the value into variable a.

Returns 0 if a is blank, otherwise, a.

 

This measure should work everywhere - No need to create more than 1! Smiley Happy The SUM function adds up all of the values in your column AFTER the column is filtered based on your selections. So, in a table, every cell that includes this value is filtered by whatever attributes are on the rows, etc. and also any slicers applied in other slicer visuals.

Hi, thanks for the response.

 

I have created the visual as well as the measure using the query supplied. 

 

How do I now apply this to the donut chart visual? once I select the measure how to I enforce?

 

With this measure to the donut visual, where the filter does not exist a 0 will be displayed as per query in the measure. How do I apply please?

Anonymous
Not applicable

@shere100 - I don't understand the requirement. Donut chart displays part-to-whole comparison. If the part is zero or blank, it wont be displayed in a donut or pie chart. I don't know of a way to show zero/blanks in a donut chart.

Apologies I meant score card. If I have a score card for each status, if the filter does not exist on the score card then to display a 0 as per query on the measure.

 

How would I embed the measure in to the score card?

Anonymous
Not applicable

@shere100 -

Here's an example of how to create a scorecard and add a column/measure to it:

Addint a Scorecard.PNG

Hi, please confirm the name of the measure in the example is called OrderQuantity? 

Anonymous
Not applicable

@shere100  - That's correct.

screenshot.PNG

 

Hi for clarity, I have included the dataset. What I am currently attempting is for each 'Teams' display the total Test Result for each selection based on the Teams column. 

 

I.e Content Support would have their own analytic view which comprise of 4 possible status's Pass, Failed, In Progress and Not Started. If any of the status's do not exist I wish to display a 0 on the score card.

 

Also, the test result status's are added and then dispalyed for each team. 

 

Please advise how I would construct this query. Thanks. 

Anonymous
Not applicable

@shere100 - For clarification, is this what you're looking for?:

 

1. A single scorecard that will count how many times each status appears for a given team? 

     -If so, that will require the measure to count the # of rows, filtered by Team(s) and Status(es)

 

Hi, that's correct but when the filter does not exist for the given team at that time to then display a 0. 

 

For example I have a score card for each status within each 'Test Status' i.e Not Started, Failed,Pased and In Progress.

 

If there is no data for 'Pass' I would like a 0 to display. 

Anonymous
Not applicable

@shere100  -

 

I think the following measure should work. Just replace 'YourTableName' with the name of the table. 

 

Count Of Status = 

var a = COUNTROWS('YourTableName')

return IF(ISBLANK(a), 0, a)

 

Hi, thanks for the response. 

 

How do I include a filter for say if a filter type did not exist currently buit with data movements it will i.e there is no pass in the test results but when data changes and there are I wish for them to be displayed on a score card.

 

How do I do this? I've checked the filter types and I cannot add a custom filter.

Anonymous
Not applicable

@shere100  - 

Start with 1 scorecard. 

Add the following Measure to the Fields area of the scorecard:

Count Of Status = 
var a = COUNTROWS('YourTableName')
return IF(ISBLANK(a), 0, a)

Add [Test Result] to the Visual Level Filters area for the scorecard, and use Advanced Filtering, like this:

Advanced Filtering Visuals.PNG

You'll want to use the Title, instead of the Category label:

Showing Title Instead of Category.PNG

Finally, copy and paste the card, and change the Advanced filter and the Title text for each card.

 

Cheers!

Nathan

 

Many thanks Nathan.

Anonymous
Not applicable

You're welcome. Thinking a bit more about this. The solution will work, but I don't think it's the most elegant way. 

You're talking about expected statuses that don't actually exist. But actually, you know what the statuses will be, right?

 

You can add another table, with the list of expected statuses.

Then create a Relationship between this table and your current table. That relationship will cause the existing table to be filtered by the new.

 

Create the following visual to show all statuses:

1.  Table visual with the Status from the new table, and the Count of Status measure.

2. Right-click the Status field, and click "Show items with no data". 

 

Each row in the table is a status - since the new table filters the existing, the existing table is limited to only the rows with that status.

Perfect, thanks for the awesome advice.

Hi, can you confirm the name of the measure in the example provided is called OrderQuantity? 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors