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

Summing Work days for entire month and to date with calendar date attached to transaction date

https://community.powerbi.com/t5/Desktop/working-day-total-working-day-running-total/td-p/195077/pag...

 

This post above is exactly what I need with calculating the max business days in the month, and also the business days in the month so far. When I try to apply these same formulas in my file it results in this errors if I use .day, .month, etc

Capture5.PNG

 

For some reason my calendar date keeps going in and out of having a heirarchy of day, month, year, quarter to just the actual date. I'm not sure if that is the cause. 

 

Part 2 of my problem is that I am connecting my calendar date to a transaction date table, and not every day has a transaction from every vendor. So I have a correct sum of working days, but when I add vendors to it, if November has 20 days - but the vendor only has 2 transactions it is only showing 2 working days instead of 20. I do not know how to get it to show just 20 no matter how many transactions. How can I work around this?

 

I cannot attach my file because it contains sensitive information. 

1 ACCEPTED SOLUTION
freder1ck
Kudo Kingpin
Kudo Kingpin

Lizsufrinko,

 

Are you trying to do this as a calculated column or with measures? 

And so you have a standard calendar or a custom calendar (for retail or manufacturing, with periods that don't match regular months)?

 

Workdays = SUM('Date'[Business Days])

Workdays MTD = CALCULATE([Workdays],
DATESMTD('Date'[Date])
)

Workdays this Month =
VAR CurrentMonth = MAX('Date'[yearmonth])
RETURN
CALCULATE([Workdays],
FILTER(ALL('Date'),
'Date'[yearmonth]=CurrentMonth)
)

Workdays MTD2 =
VAR CurrentDay = MAX(Date[Date])
VAR CurrentMonth = MAX('Date'[yearmonth])
RETURN
CALCULATE([Workdays],
FILTER(ALL('Date'),
Date[Date] <= CurrentDay &&
'Date'[yearmonth] = CurrentMonth))

If you're using a standard calendar, Workdays MTD should work. If you're using a custom calendar, Workdays MTD2 would work.

 

I'm assuming that you're putting dates or weeks from your date calendar on table rows...

View solution in original post

1 REPLY 1
freder1ck
Kudo Kingpin
Kudo Kingpin

Lizsufrinko,

 

Are you trying to do this as a calculated column or with measures? 

And so you have a standard calendar or a custom calendar (for retail or manufacturing, with periods that don't match regular months)?

 

Workdays = SUM('Date'[Business Days])

Workdays MTD = CALCULATE([Workdays],
DATESMTD('Date'[Date])
)

Workdays this Month =
VAR CurrentMonth = MAX('Date'[yearmonth])
RETURN
CALCULATE([Workdays],
FILTER(ALL('Date'),
'Date'[yearmonth]=CurrentMonth)
)

Workdays MTD2 =
VAR CurrentDay = MAX(Date[Date])
VAR CurrentMonth = MAX('Date'[yearmonth])
RETURN
CALCULATE([Workdays],
FILTER(ALL('Date'),
Date[Date] <= CurrentDay &&
'Date'[yearmonth] = CurrentMonth))

If you're using a standard calendar, Workdays MTD should work. If you're using a custom calendar, Workdays MTD2 would work.

 

I'm assuming that you're putting dates or weeks from your date calendar on table rows...

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.