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
Anonymous
Not applicable

Count ID only if other column is not blank for all rows

I have a dataset full of "vendor IDs" that can be added and expired in different markets. I want to be able to track if a Vendor ID has been expired in all instances so with the screenshot below, the count would be zero because not all expiration dates are populated. If they were, I would want the count to be one. Is there a way to do this with DAX measures?

Capture.PNG

 
 
 
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Hmm, assuming that we have vendor_id in the visualization:

 

Count Measure = 

  VAR __Count1 = COUNTROWS('Table')

  VAR __Count2= COUNTROWS(FILTER('Table',NOT(ISBLANK('Table'[expiration_date]))))

RETURN

  IF(__Count1 = __Count2,1,0)

 

For all vendor ID's you might have to do something like:

 

Count Measure = 

  VAR __Table = 

    SUMMARIZE(

      'Table',

      [vendor_id],

      "__Count1" = COUNTROWS('Table'),

      "__Count2" = COUNTROWS(FILTER('Table',NOT(ISBLANK('Table'[expiration_date]))))

  )

RETURN

  COUNTROWS(FILTER(__Table,[__Count1] = [__Count2]))


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

Hmm, assuming that we have vendor_id in the visualization:

 

Count Measure = 

  VAR __Count1 = COUNTROWS('Table')

  VAR __Count2= COUNTROWS(FILTER('Table',NOT(ISBLANK('Table'[expiration_date]))))

RETURN

  IF(__Count1 = __Count2,1,0)

 

For all vendor ID's you might have to do something like:

 

Count Measure = 

  VAR __Table = 

    SUMMARIZE(

      'Table',

      [vendor_id],

      "__Count1" = COUNTROWS('Table'),

      "__Count2" = COUNTROWS(FILTER('Table',NOT(ISBLANK('Table'[expiration_date]))))

  )

RETURN

  COUNTROWS(FILTER(__Table,[__Count1] = [__Count2]))


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

So that count is working for the complete total count, but doesn't work when monthly/daily filters are applied. I've been trying to calculate a running total of all vendors by day:

 

Total Vendor IDs =
CALCULATE(DISTINCTCOUNT('Plan Allocation Spread'[vendor_id]),
FILTER(
GROUPBY(ALLSELECTED('Plan Allocation Spread'),
'Plan Allocation Spread'[load_date],'Spread Calendar'[Date]),
'Plan Allocation Spread'[load_date]<=MAX('Spread Calendar'[Date])),
'Plan Allocation Spread'[expiration_date] = BLANK()
)
 
Is there a way to groupby in a similar way for the expired measure to capture the daily change?
Anonymous
Not applicable

Yes! This is pulling in the correct number I'm looking for.

Thanks so much!

Great! 🙂

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

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