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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
sunnyS
Frequent Visitor

Help with Dax

Hi there, I'm new to power bi and working on a sales report. I'm a little stuck with the following problem and was hoping to get some help. 

 

I have a store table that lists all of the stores in our district. I also have a sales table that has the orders and stores we sold to. They are joined together by a store number(primary key in the stores table). I'm trying to create a visualization from a measure that lists the stores we are NOT in. Any help with the DAX or other solutions would be greatly appreciated. 

 

Thank you! 

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

One way is to make table visual with the Stores[Store] column (or whatever you've called it) and a measure like this:

 

Stores without Sales =
COUNTROWS ( FILTER ( Stores, ISBLANK ( CALCULATE ( COUNTROWS ( Sales ) ) ) ) )

 

This will return blank for all stores that had sales, and give you the count of stores w/o sales (in your table, each Store will have a count of 1 and blanks will be automatically eliminated).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Here is brief explanation of how it works

 

Stores without Sales =
COUNTROWS ( FILTER ( Stores, ISBLANK ( CALCULATE ( COUNTROWS ( Sales ) ) ) ) )

 

The FILTER function is an iterator, so it starts with the rows of the Stores table in the current context (i.e., filtered by any slicers or elements on the visuals), it then calculates the rows of the Sales table filtered by the current row (the CALCULATE() triggers "context transition" to do pass the current row as a filter on the Sales table through that relationship).  FILTER returns all the rows that evalute as True(), so only the Stores that have no Sales satisfy that condition.  Then we just count the rows that pass the filter.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
edhans
Super User
Super User

If you have a Total Sales measure, something like:

Total Sales = SUM(SalesData[Sales])

You can create a visual and filter it to show only where Total Sales is blank. You will need to make sure your Store name/number/key is set to show items without data.

So basically, no DAX needed. You just need to filter and set the visual properties

2020-06-15 16_03_50-Untitled - Power BI Desktop.png



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
mahoneypat
Microsoft Employee
Microsoft Employee

One way is to make table visual with the Stores[Store] column (or whatever you've called it) and a measure like this:

 

Stores without Sales =
COUNTROWS ( FILTER ( Stores, ISBLANK ( CALCULATE ( COUNTROWS ( Sales ) ) ) ) )

 

This will return blank for all stores that had sales, and give you the count of stores w/o sales (in your table, each Store will have a count of 1 and blanks will be automatically eliminated).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thank you @mahoneypat. Your solution worked. Quick question: Is your formula cross referencing the sales foreign key to the stores primary key? I'm just trying to figure out how it worked. Thank you

 

Here is brief explanation of how it works

 

Stores without Sales =
COUNTROWS ( FILTER ( Stores, ISBLANK ( CALCULATE ( COUNTROWS ( Sales ) ) ) ) )

 

The FILTER function is an iterator, so it starts with the rows of the Stores table in the current context (i.e., filtered by any slicers or elements on the visuals), it then calculates the rows of the Sales table filtered by the current row (the CALCULATE() triggers "context transition" to do pass the current row as a filter on the Sales table through that relationship).  FILTER returns all the rows that evalute as True(), so only the Stores that have no Sales satisfy that condition.  Then we just count the rows that pass the filter.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@sunnyS , You need to create sales with +0 and filter the sales =0 when plot sales by store

 

Sales = sum(Table[net sales])+0.

 

You can use this option and filter for null

ShowItemwithoutdata.JPG

 

You can get using except

except(all(store[store]),all(sales[store]))

 

refer this file how to use this in clause of measure

https://www.dropbox.com/s/3wr697b3m57zufo/ExceptOther%20Tabl.pbix?dl=0

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors