Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi All, I have a dataset that is getting dates list between start date time and end date time and students that are scheduled for courses,
start datetime | end datetime | StudentID | List dates | Courses | Scheduled |
11/16/2022 12:06pm | 2/28/2023 12:00pm | 15 | 1/10/2023 | Math | TRUE |
11/16/2022 12:06pm | 2/28/2023 12:00pm | 15 | 1/10/2023 | Chem | TRUE |
created a new column "scheduled" to check if a student is scheduled for a course at 8 am everyday by using
"at 8am = var _1 = date(year(list dates),month(list dates),day(list dates)+TIME (8,0,0)
Return
IF ( _1 <= end datetime && _1 >= start date time || _1-1 < end datetime && _1-1 >= start datetime, "TRUE","FALSE") "
My question is if a student is schedueld for more than one subject at the same time on any given day I want CHEM to be TRUE and not math
Expected result
start datetime | end datetime | StudentID | List dates | Courses | Scheduled |
11/16/2022 12:06pm | 2/28/2023 12:00pm | 15 | 1/10/2023 | Math | FALSE |
11/16/2022 12:06pm | 2/28/2023 12:00pm | 15 | 1/10/2023 | Chem | TRUE |
Thanks in advance
Really appreciate any help.
Solved! Go to Solution.
Hi @Rt0790 ,
Please try to create a new column with below dax formula:
Column =
VAR ed = [end datetime]
VAR sd = [start datetime]
VAR _id = [StudentID]
VAR cse = [Courses]
VAR tmp =
SUMMARIZE (
'Table',
'Table'[StudentID],
'Table'[List dates],
'Table'[start datetime],
'Table'[end datetime],
"Ctn", COUNTROWS ( 'Table' )
)
VAR tmp1 =
CALCULATETABLE ( VALUES ( 'Table'[StudentID] ), FILTER ( tmp, [Ctn] >= 2 ) )
VAR _1 =
DATE ( YEAR ( [List dates] ), MONTH ( [List dates] ), DAY ( [List dates] ) + TIME ( 8, 0, 0 ) )
VAR _flg =
IF ( _1 <= ed && _1 >= sd || _1 - 1 < ed && _1 - 1 >= sd, "TRUE", "FALSE" )
RETURN
SWITCH (
TRUE (),
_id
IN tmp1
&& cse = "Chem",
IF ( _1 <= ed && _1 >= sd || _1 - 1 < ed && _1 - 1 >= sd, "TRUE", "False" ),
_id
IN tmp1
&& cse <> "Chem", "False",
NOT ( _id IN tmp1 ),
IF ( _1 <= ed && _1 >= sd || _1 - 1 < ed && _1 - 1 >= sd, "TRUE", "FALSE" )
)
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Rt0790 ,
Please try to create a new column with below dax formula:
Column =
VAR ed = [end datetime]
VAR sd = [start datetime]
VAR _id = [StudentID]
VAR cse = [Courses]
VAR tmp =
SUMMARIZE (
'Table',
'Table'[StudentID],
'Table'[List dates],
'Table'[start datetime],
'Table'[end datetime],
"Ctn", COUNTROWS ( 'Table' )
)
VAR tmp1 =
CALCULATETABLE ( VALUES ( 'Table'[StudentID] ), FILTER ( tmp, [Ctn] >= 2 ) )
VAR _1 =
DATE ( YEAR ( [List dates] ), MONTH ( [List dates] ), DAY ( [List dates] ) + TIME ( 8, 0, 0 ) )
VAR _flg =
IF ( _1 <= ed && _1 >= sd || _1 - 1 < ed && _1 - 1 >= sd, "TRUE", "FALSE" )
RETURN
SWITCH (
TRUE (),
_id
IN tmp1
&& cse = "Chem",
IF ( _1 <= ed && _1 >= sd || _1 - 1 < ed && _1 - 1 >= sd, "TRUE", "False" ),
_id
IN tmp1
&& cse <> "Chem", "False",
NOT ( _id IN tmp1 ),
IF ( _1 <= ed && _1 >= sd || _1 - 1 < ed && _1 - 1 >= sd, "TRUE", "FALSE" )
)
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, I tried this on a similar dataset and I get the following error, "Argument of function 'DATE' has the wrong data type or the result is too large or too small".
Hi -
One very way to do this, which I think is a bit crude but might work, is to group on the fields you have shown above in the Power Query editor, and add a row number for the Courses Scheduled subject. A technique for adding an index on groups is here:
https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query
Then you would add a condition in your forumula to check to see if the index of the group was "1", which would correspond with "CHEM" in the grouping because it comes ahead of math. It isn't pretty but I think it would work.
Hope this helps,
Peter
User | Count |
---|---|
20 | |
14 | |
11 | |
8 | |
6 |
User | Count |
---|---|
23 | |
23 | |
20 | |
15 | |
10 |