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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Slicer Filter Isn't working to filter a grid when I include a measure

My data model is setup similar to this... 

 

Sales Rep Table

Sales Rep ID Sales Rep Name

1Brad
2Lisa

 

Customer Table

Company ID Company Name Sales Rep ID

1ABC Company2
2XYZ Company1
3DEF Company2
4GHK Company1

 

Sales Table

SalesId Company ID Amount

14$200
22$150
31$50
42$175
51$200
61$100
71$25

 

My relationship between Sales Rep and Company is a 1 -> Many based on Sales Rep ID and between Company and Sales is a 1 -> Many based on Company ID

 

On the Sales table I have two measures defined:

 

Total Sales Amount = SUM('Sales'[Amount])

 

Total Sales Count = COUNTROWS('Sales')

 

Now I have a grid visual where I list the Company Information and the two sales measures.. so the grid looks like this

Company ID Company Name Sales Count Sales Total

1ABC Company4$375
2XYZ Company2$325
3DEF Company  
4GHK Company1$200

 

And I have a Slicer with the Sales Rep's Name so if I select a Sales Rep, it filters and just shows the Sales for the Companies that are assigned to the selected Sales Rep

 

In the Grid, for Company ID 3 it leaves the Sales Count and Sales Total blank... because there are no Sales... but I want it to show zeros in those columns instead of blanks... so I updated the 'Total Sales Count' and 'Total Sales Amount' measures to look like this... 

 

Total Sales Amount =  var amount = var amount = SUM('Sales'[Amount]) return IF(amount = BLANKS(), 0, 1)

 

Total Sales Count = var count = COUNTROWS('Sales') return IF(count = BLANKS(), 0, 1)

 

But now, when I select 'Brad' in my Sales Rep Slicer... this is what I get

Company ID Company Name Sales Count Sales Total

1ABC Company0$0
2XYZ Company2$325
3DEF Company0$0
4GHK Company1$200

 

And when I select 'Lisa' I get....

Company ID Company Name Sales Count Sales Total

1ABC Company4$375
2XYZ Company0$0
3DEF Company0$0
4GHK Company0$0

 

the grid shows All companies (it doesn't filter to show just the companies assigned to the selected Sales Rep) but what for companies not assigned to the selected Sales Rep, it shows zeros for the Sales Count and Sales Amount... it only shows the Sales Count and Sales Amounts for the Companies assigned to the selected Sales Rep...

 

it works exactly how I want it to when the measures return blanks when there aren't any records.. 

 

How can I get this to work... and have my measures return zeros instead of Blanks... I'm not understanding what is happening here.

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

See if this works

The model:
model.jpg

The measures:

 

Sales + 0 =
SUMX (
    ADDCOLUMNS (
        VALUES ( 'Company Table'[Company ID] ),
        "Val", SUM ( 'Sales Table'[Amount] ) + 0
    ),
    [Val]
)

Count + 0 = IF(
    [Sales + 0] == 0, 0, COUNTROWS('Sales Table'))

 

Result.jpg

 

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

See if this works

The model:
model.jpg

The measures:

 

Sales + 0 =
SUMX (
    ADDCOLUMNS (
        VALUES ( 'Company Table'[Company ID] ),
        "Val", SUM ( 'Sales Table'[Amount] ) + 0
    ),
    [Val]
)

Count + 0 = IF(
    [Sales + 0] == 0, 0, COUNTROWS('Sales Table'))

 

Result.jpg

 

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






jdbuchanan71
Super User
Super User

@Anonymous 

Take a look at this article that discusses the topic you are asking about.

https://www.sqlbi.com/articles/how-to-return-0-instead-of-blank-in-dax/

The topic is a bit more complex than it seems at first glance.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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