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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
etane
Helper V
Helper V

Cases per Day Calculation

Hello.  

 

I am trying to divide total cases by shipping days and display it on a matrix table with year and month in the column.

 

I can't figure out how to get the cases per day to show.  So, in the year total, I should get total cases for that year divided by total shipping days in that year.  Conversely, in each month, I should get total cases for that month divided by total shipping days in that month.  

 

For example, in January 2026, there were 70 cases and 21 shipping days.  So, cases per day should be 70/21 = 3.33.  And, for 2025, 698/253 = 2.75


However, I can't come up with a dax that does this calculation.  Help.

 

Sample file here: Link

Thanks.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Add a new column onto your calendar table to flag whether a day is a holiday or not. You can change the existing ADDCOLUMNS to be

Calendar =

VAR Days = CALENDAR(DATE(year(TODAY())-7,1,1),DATE(year(today())+1,12,31))
VAR Holidays = {
        (1, 1),   
        (2, 19),  
        (5, 27),  
        (7, 4),   
        (9, 2),   
        (11, 28), 
        (11, 29), 
        (12, 24), 
        (12, 25)  
    }
Return ADDCOLUMNS(
    Days,
    "Today", TODAY(),
    "Year#", YEAR([Date]),
    "Year", FORMAT(YEAR([Date]),"#"),
    "Month#", VALUE(FORMAT(MONTH([Date]),"#")),
    "Month Number",FORMAT([Date],"MM"),
    "Month", FORMAT([Date],"mmm"),
    "Quarter#",QUARTER([Date]),
    "Quarter","Q"&FORMAT([Date],"Q"),
    "Year Month", FORMAT([Date],"YYYYMM"),
    "Year Quarter", FORMAT(YEAR([Date]),"#") &"Q"&FORMAT([Date],"Q"),
    "Week Number", FORMAT(WEEKNUM([Date]),"00"),
    "Week In Month",FORMAT(WEEKNUM([Date],2) - WEEKNUM(EOMONTH([Date],-1)+1,2)+1,"#"),
    "Is Holiday", ( MONTH( [Date] ), DAY( [Date] ) ) IN Holidays
    )

You can then change the [Shipping Days] measure to be

Shipping Days = VAR MinDate = MIN( Calendar[Date] )
VAR MaxDate = MAX( Calendar[Date] )
VAR Holidays = CALCULATETABLE(
    VALUES( Calendar[Date]),
    Calendar[Is Holiday] = TRUE
)
VAR WorkingDays = NETWORKDAYS( MinDate, MaxDate, 1, Holidays)
RETURN WorkingDays

And the [Case per Ship Day] stays the same.

You should also change the relationship between Calendar and the fact table to be single direction, there's no need for it to be bi-directional.

See the attached PBIX for a working sample.

 

 

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

Add a new column onto your calendar table to flag whether a day is a holiday or not. You can change the existing ADDCOLUMNS to be

Calendar =

VAR Days = CALENDAR(DATE(year(TODAY())-7,1,1),DATE(year(today())+1,12,31))
VAR Holidays = {
        (1, 1),   
        (2, 19),  
        (5, 27),  
        (7, 4),   
        (9, 2),   
        (11, 28), 
        (11, 29), 
        (12, 24), 
        (12, 25)  
    }
Return ADDCOLUMNS(
    Days,
    "Today", TODAY(),
    "Year#", YEAR([Date]),
    "Year", FORMAT(YEAR([Date]),"#"),
    "Month#", VALUE(FORMAT(MONTH([Date]),"#")),
    "Month Number",FORMAT([Date],"MM"),
    "Month", FORMAT([Date],"mmm"),
    "Quarter#",QUARTER([Date]),
    "Quarter","Q"&FORMAT([Date],"Q"),
    "Year Month", FORMAT([Date],"YYYYMM"),
    "Year Quarter", FORMAT(YEAR([Date]),"#") &"Q"&FORMAT([Date],"Q"),
    "Week Number", FORMAT(WEEKNUM([Date]),"00"),
    "Week In Month",FORMAT(WEEKNUM([Date],2) - WEEKNUM(EOMONTH([Date],-1)+1,2)+1,"#"),
    "Is Holiday", ( MONTH( [Date] ), DAY( [Date] ) ) IN Holidays
    )

You can then change the [Shipping Days] measure to be

Shipping Days = VAR MinDate = MIN( Calendar[Date] )
VAR MaxDate = MAX( Calendar[Date] )
VAR Holidays = CALCULATETABLE(
    VALUES( Calendar[Date]),
    Calendar[Is Holiday] = TRUE
)
VAR WorkingDays = NETWORKDAYS( MinDate, MaxDate, 1, Holidays)
RETURN WorkingDays

And the [Case per Ship Day] stays the same.

You should also change the relationship between Calendar and the fact table to be single direction, there's no need for it to be bi-directional.

See the attached PBIX for a working sample.

 

 

Thank you!  I love how easy it is to apply your solution.

cengizhanarslan
Super User
Super User

Please try the logic below:

 

Cases per Day =
VAR _TotalCases =
SUM ( FactCases[Cases] )
VAR _ShippingDays =
SUM ( FactCases[ShippingDays] )
RETURN
DIVIDE ( _TotalCases, _ShippingDays )
_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Thanks.  I don't see how I can sum the number of shipping days.  

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.