Free Republic
Browse · Search
General/Chat
Topics · Post Article

Skip to comments.

To Count Working Days in any Month with DAX
Now | Me

Posted on 03/09/2021 3:18:08 PM PST by FourtySeven

haha ok, really?!? No one has bothered to post this for struggling newbies in DAX like me? In the words of our bumbling leader "C'mon Man!"

Yeah ok, I get that DAX whizes probably figured this out on their first day but whatever.

Thought I'd post this here, so maybe it'll show up on some search somewhere, and help a poor schlep like me out sometime, working through this for the last few WEEKS, going nowhere with this. (this is why I haven't posted anything about election irregularities by the way in recent weeks, been struggling with this dang WORK problem, now I gotta go back and code everything differently because I worked around it anyway...)

Not to mention most DAX "help" is posted in the syntax of German users using the ";" in place of the "," thanks ya dang Krauts.

Anyway assuming one has a (pretty much) standard date table with something like below (the critical column is the [DayofWeekNumber]):

Date = ADDCOLUMNS(CALENDAR(DATE(2015,1,1), DATE(2050,12,31)), "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), "Year", YEAR ( [Date] ), "MonthNumber", FORMAT ( [Date], "MM" ), "YearMonthNumber", FORMAT ( [Date], "YYYY/MM" ), "YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ), "MonthNameShort", FORMAT ( [Date], "mmm" ), "MonthNameLong", FORMAT ( [Date], "mmmm" ), "DayOfWeekNumber", WEEKDAY ( [Date] ), "IsWorkingDay", NOT WEEKDAY( [Date] ) IN {1,7}, "DayOfWeek", FORMAT ( [Date], "dddd" ), "DayOfWeekShort", FORMAT ( [Date], "ddd" ), "Quarter", "Q" & FORMAT ( [Date], "Q" ), "YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ) )

Then use this dang DAX for a calculated column:

Working Day Count = SWITCH ('Date'[DayOfWeekNumber],7,0,6,1,5,1,4,1,3,1,2,1,1,0)

THAT is what took me literally the last two weeks to figure out ......sheesh....

I had to post this somewhere. Flame away for my stupidity yes, those who are DAX gods. Actually I wouldn't mind a bit of flaming for this, because really I should've figured it out sooner, but yeah, stuck for two weeks, coded around it, now I gotta go BACK and change alllllll these other column names blah blah blah.....so yeah won't be around for a while again.

In all seriousness, hope it helps someone. Lots more work now so again, another FR/Internet Fun wherever hiatus.........


TOPICS: Computers/Internet
KEYWORDS: huh; wut
Navigation: use the links below to view more comments.
first previous 1-2021-30 last
To: ProtectOurFreedom

</like> I like jazz.......RETURN
“I like jazz”....
Or something like that.


21 posted on 03/15/2021 5:26:57 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 19 | View Replies]

To: drSteve78

Thank you.

The problem is, I don’t have a pencil.

(or a calendar)


22 posted on 03/15/2021 5:27:49 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 15 | View Replies]

To: higgmeister

I don’t see DAX listed there.

Must be an oversight.

</oversight>

SUMMARY(’Oversight’[Oversight1], ‘Return table[Date],[Date],’Order Summary[Order Date], [Date].[Date], 0,True)


23 posted on 03/15/2021 5:31:01 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 17 | View Replies]

To: Macoozie

Don’t forget M!


24 posted on 03/15/2021 5:31:50 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 14 | View Replies]

To: Larry Lucido

Was I not supposed to post this thread?

Was that bad?

</costanza>


25 posted on 03/15/2021 5:32:43 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 7 | View Replies]

To: WinMod70
I’m guessing that you’re one of the laid off pipeline workers that jumped right into the programmer field. Looks like the transition is going well.

Yes! I figger I should have the oxetane line linked to the CO2 tank in no time...............

(did I fake it enough there? I wonder if Crazy Uncle Joe would hire me)

26 posted on 03/15/2021 5:34:36 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 6 | View Replies]

To: SauronOfMordor

Yes! Close () of course.


27 posted on 03/15/2021 5:35:17 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 10 | View Replies]

To: rfp1234

*sigh* Terry Farrell

</dreamy music>


28 posted on 03/15/2021 5:36:38 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 4 | View Replies]

To: FourtySeven
Now if you used Excel, you could use a much simpler formula such as this:

=NETWORKDAYS (start_date, end_date, [holidays])

The holidays part is optional.

29 posted on 03/15/2021 5:40:19 PM PDT by SamAdams76 (By stealing Trump's second term, the Left gets Trump for 8 more years instead of just four.)
[ Post Reply | Private Reply | To 1 | View Replies]

To: SamAdams76

*SiGH*

Tell me about it!

I mean that’s ALL a brotha is asking for in DAX ... who thought it was a good idea to remove that function?!

Oh yeah....DAX is all about columns.....yah yeah whatever...unghh


30 posted on 03/15/2021 6:32:11 PM PDT by FourtySeven (47)
[ Post Reply | Private Reply | To 29 | View Replies]


Navigation: use the links below to view more comments.
first previous 1-2021-30 last

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
General/Chat
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson