Forum Discussion
Need Help_Dax
- 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.
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