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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
webportal
Impactful Individual
Impactful Individual

Define the granularity for "day" when calculating NumOfDays?

Hello,

 

When calculating the average sales per day, I have the following measure for NumOfDays:

 

NumOfDays = IF (
    [Sales Amount] > 0; 
    COUNTROWS ( Date )
)

What this is doing is removing the number of days for those dates when there are no sales.

 

Thus, I have the following visual:

Capturar.JPG

 

As you can see, the total is wrong. 

This is due to the fact that the database has more years than those shown in the matrix. 

How can I define the granularity for "day" when calculating NumOfDays?

That is, how can I count the rows for those days with sales only?

 

Thanks!

Man Happy

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @webportal,

 

In your scenario, you can create a measure like below:

 

NumOfDays = CALCULATE(COUNTROWS('Adventure Works'),FILTER('Adventure Works',SUM('Adventure Works'[Internet Sales Amount])>0))

 

q4.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-qiuyu-msft
Community Support
Community Support

Hi @webportal,

 

In your scenario, you can create a measure like below:

 

NumOfDays = CALCULATE(COUNTROWS('Adventure Works'),FILTER('Adventure Works',SUM('Adventure Works'[Internet Sales Amount])>0))

 

q4.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Sure, that one is working, thank you!

 

Also, this one:

 

NumOfDays2 =
CALCULATE (
    DISTINCTCOUNT ( 'Date'[Date] );
    FILTER ( 'Date'; Sales[Sales Amount] > 0 )
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors