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
atul__1984
New Member

COUNT on DAX measure

Hi,

 

I have list of retailers. All respective column have been created with the help of DAX Measures.  Now my challenge is that I need to find COUNT OF RETAILERS falling in each slab.  Below are measures for each value

 

First Date = CALCULATE(MIN(Calendar_Lookup[Date]),ALLSELECTED(Calendar_Lookup[Date]))

Last Date = CALCULATE(MAX(Calendar_Lookup[Date]),ALLSELECTED(Calendar_Lookup[Date]))

Count of Days = CALCULATE(COUNT(Calendar_Lookup[Date]), DATESBETWEEN(Calendar_Lookup[Date],[First Date],[Last Date]))

Invoice Days = IFERROR(CALCULATE(DISTINCTCOUNT(Invoice[invoice_date]), FILTER(Invoice,Invoice[retailerId])),0)

Invoice Days % = IFERROR(Invoice[Invoice Days] / [Count of Days], 0)


Invoice Day % Slab =
IF(Invoice[Invoice Days %] = 0 || ISBLANK(Invoice[Invoice Days %]) ,"0%",
IF(Invoice[Invoice Days %] > 0 && Invoice[Invoice Days %] <= 0.1,"1% - 10%",
IF(Invoice[Invoice Days %] > 0.1 && Invoice[Invoice Days %] <= 0.2, "11% - 20%",
If (Invoice[Invoice Days %] > 0.2 && Invoice[Invoice Days %] <= 0.35, "21% - 35%",
If (Invoice[Invoice Days %] > 0.35 && Invoice[Invoice Days %] <= 0.5, "35% - 50%",
If (Invoice[Invoice Days %] > 0.5 && Invoice[Invoice Days %] <= 0.75, "51% - 75%", "76% - 100%"))))))

 

I can not not use COUNT on a DAX Measure since it works on Column only.  

 

Retailer NameCount of DaysInvoice DaysInvoice Days %Invoice Day % Slab
A1484288%76% - 100%
A2483879%76% - 100%
A3482960%51% - 75%
A4482858%51% - 75%
A5482756%51% - 75%
A6482654%51% - 75%
A7482654%51% - 75%
A8482552%51% - 75%
A9482348%35% - 50%
A10482348%35% - 50%

 

I want output like below. 

 

Invoice Day % SlabCount
0%5
1% - 10%982
11% - 20%66
21% - 35%115
35% - 50%32
51% - 75%6
76% - 100%2

 

Second challenge is that DAX calculations are very slow and I have ever growing list. If there is any other more efficient way, please advise.

 

Thanks & Best Regards

2 REPLIES 2
jthomson
Solution Sage
Solution Sage


@atul__1984 wrote:

 

Second challenge is that DAX calculations are very slow and I have ever growing list. If there is any other more efficient way, please advise.

 

Thanks & Best Regards


I wouldn't have necessarily thought this would improve speed, but it would make your statements more user friendly, at least to read:

 

maketheifcleaner.PNG

 

Assuming [Invoice Days %] can't be negative, then everything I've crossed out in pink is superfluous, as every single entry would hit that condition at that stage of the statement anyway. Second line I've pinked through for example - you've already chosen everything that's between 0% and 10%, telling the measure to check it's over 10% is redundant

amitchandak
Super User
Super User

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.