cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
depple Regular Visitor
Regular Visitor

Count Blanks Table

Hi, 

 

I have a dataset with a table containing all stores and another table with sales. Not all stores have sales. How do I count the number of stores with no sales? I have looked into the COUNTBLANK, but I don't think it can help me, given my data structure.

 

My dataset is like this

 

Table A

|Store|

Store A

Store B

Store C

Store D

Store E

 

 

Table B

|SalesID|Store|Quantity|

01 Store C 10

02 Store D 5

03 Store A 20

 

How do I count the number of stores with zero sales? In the example above, the answer should be 2 (Store B and E).

 

Any help will be highly appreciated.

 

/depple

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Count Blanks Table

If you have a measure that calculates sales.

Sales = SUM ( 'Table B'[qty] )

You can use that in a COUNTROWS measure over your stores

No Sales = 
CALCULATE(
    COUNTROWS( 'Table A' ),
    FILTER(
        'Table A',
        [Sales] = 0
    )
)
4 REPLIES 4
Super User
Super User

Re: Count Blanks Table

If you have a measure that calculates sales.

Sales = SUM ( 'Table B'[qty] )

You can use that in a COUNTROWS measure over your stores

No Sales = 
CALCULATE(
    COUNTROWS( 'Table A' ),
    FILTER(
        'Table A',
        [Sales] = 0
    )
)
MitchM Member
Member

Re: Count Blanks Table

jdbuchanan71's solution works perfect as long as you are able to relate the two tables. If you cannnot relate the tables in the data model you can try this:

Stores with No Sales = 
VAR TotalStores = DISTINCTCOUNT( 'Table A'[Store] )
VAR StoresWithSales =
    CALCULATE(
        DISTINCTCOUNT( 'Table A'[Store] ),
        TREATAS( 
            SUMMARIZE( 'Table B', 'Table B'[Store] ),
            'Table A'[Store]
        )
    )
RETURN
    TotalStores - StoresWithSales

samples2.jpg

 

depple Regular Visitor
Regular Visitor

Re: Count Blanks Table

It works perfect.

 

Thx a million!

 

/depple

depple Regular Visitor
Regular Visitor

Re: Count Blanks Table

Hi,

 

I have a connection between the tables, so @jdbuchanan71 helped me.

 

Thank you so much for taking time to show an alternative solution. 

 

/depple

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 112 members 1,729 guests
Please welcome our newest community members: