Forum Discussion
Rt0790
3 years agoRegular Visitor
Need Help_Dax
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 ...
- Anonymous3 years ago
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.
Anonymous
3 years agoNot applicable
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.
Rt0790
3 years agoRegular Visitor
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".