March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello everyone, I have a dax for counting the number of days for Monday, Tuesday, Wednesday, Thursday, Friday, Saturday Sunday at the month.
But the DayofTeachCount is not exactly because 3 of Fridays are not time for teaching
The visual right must have be : DayofTeachRight = 10
I make a power BI file with table data in this link:https://drive.google.com/file/d/1KRmfetcp4tVrf2Xti2HMZRFnMJELpvTU/view?usp=drive_link
Please everyone help me add a condition into dax DayOfTeachCount : if StartTime > 0 and EndTime > 0 to count the number of days of Monday, Tuesday, ..., if StartTime = 0 and EndTime = 0 then the day is not counted.
Thank a lot
You can create a kind of multiplier:
Multiplier =
SUMX('Teacher Schedule', IF('Teacher Schedule'[StartTime]="0",0,1))
And then, modify your measure:
DayOfTeachCount =
VAR SelectedWeekStart = MIN ('Teacher Schedule'[Date])
VAR SelectedWeekEnd = MAX ('Teacher Schedule'[Date])
VAR Starttime = VALUE(SELECTEDVALUE('Teacher Schedule'[StartTime]))
VAR Endtime = VALUE(SELECTEDVALUE('Teacher Schedule'[EndTime]))
VAR Result =
SUMX(
VALUES ( 'Teacher Schedule'[Date]),
SWITCH (
WEEKDAY ( 'Teacher Schedule'[Date],2),
1, IF ( 'Teacher Schedule'[Date] >= SelectedWeekStart && 'Teacher Schedule'[Date] <= SelectedWeekEnd, 1*[Multiplier], 0 ),
2, IF ( 'Teacher Schedule'[Date] >= SelectedWeekStart && 'Teacher Schedule'[Date] <= SelectedWeekEnd, 1*[Multiplier], 0 ),
3, IF ( 'Teacher Schedule'[Date] >= SelectedWeekStart && 'Teacher Schedule'[Date] <= SelectedWeekEnd, 1*[Multiplier], 0 ),
4, IF ( 'Teacher Schedule'[Date] >= SelectedWeekStart && 'Teacher Schedule'[Date] <= SelectedWeekEnd, 1*[Multiplier], 0 ),
5, IF ( 'Teacher Schedule'[Date] >= SelectedWeekStart && 'Teacher Schedule'[Date] <= SelectedWeekEnd, 1*[Multiplier], 0 ),
6, IF ( 'Teacher Schedule'[Date] >= SelectedWeekStart && 'Teacher Schedule'[Date] <= SelectedWeekEnd, 1*[Multiplier], 0 ),
7, IF ( 'Teacher Schedule'[Date] >= SelectedWeekStart && 'Teacher Schedule'[Date] <= SelectedWeekEnd, 1*[Multiplier], 0 ),
BLANK ()
)
)
Return Result
But why 10? Because of Saturdays and Sundays?
Hi @mlsx4 ,
You can see data in power BI file , the Friday that teacher have no schedule .
Hi @mlsx4 ,
Total DayofTeach = 10 ( because Friday is not teach) , and another is count distinct because at one day have many time for teaching .
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
8 |
User | Count |
---|---|
37 | |
32 | |
16 | |
16 | |
12 |