Forum Discussion
Join 2 table with additional calculated columns using dax
- Anonymous2 years ago
Hi juhoneyighot ,
Thanks for the reply from lbendlin , please allow me to provide another insight:
Based on the two tables you provided, enter Power Query and select Merge Queries as New.
After the merge is completed, select the expand button in the upper right corner and select the corresponding column.
The table after data cleaning is as follows.
Create two calculated columns to calculate the status of start time and end time respectively.
Start Time Status = VAR _hour = HOUR ( 'New Table'[Start Date ] ) - HOUR ( 'New Table'[Available Start] ) VAR _minutes = MINUTE ( 'New Table'[Start Date ] ) - MINUTE ( 'New Table'[Available Start] ) RETURN IF ( HOUR('New Table'[Start Date ]) < HOUR('New Table'[Available Start]), "Early Log-in", IF ( AND ( 'New Table'[Start Date ] >= 'New Table'[Available Start], AND ( _hour = 0, _minutes <= 10 ) ), "On-Time", "Late-Log-In" ) ) End Time Status = VAR _hour = HOUR ( 'New Table'[End Date] ) - HOUR ( 'New Table'[Available End] ) VAR _minutes = MINUTE ( 'New Table'[End Date] ) - MINUTE ( 'New Table'[Available End] ) RETURN IF ( HOUR ( 'New Table'[End Date] ) < HOUR ( 'New Table'[Available End] ), "Early Log-out", IF ( AND ( 'New Table'[End Date] >= 'New Table'[Available End], AND ( _hour = 0, _minutes <= 10 ) ), "On-Time", "Late Log-Out" ) )Drag the required fields to the report page for display. The page effect is as follows:
pbix file is attached.
If you have any further questions please feel free to contact me.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot! - 2 years ago
Start Time Status = SWITCH(TRUE(),
[Start Delta]>10,"Late Log-in",
[Start Delta]<0,"Early Log-in",
"On-Time")
I would simplify the ask
See attached. Note the data model. No need for any programmatic joins.
Applied the insights and it looks like this.
This is a simplified one.
I've tried to get the Start /End Time Status
Use this DAX measure:
Start Time Status = SWITCH(
TRUE,
[Start Delta]>10="Late Log-in",
[Start Delta]<0="Early Log-in",
[Start Delta]>=0 && [Start Delta]<=10,"On-Time",
""
)
However, as Ive added this on the visual error occurs
Or I'm thinking for a calculated column but I am not sure what formula I could use since there are multiple conditions. I hope you could help me on this.
Thank you
- lbendlin2 years agoSuper User
Start Time Status = SWITCH(TRUE(),
[Start Delta]>10,"Late Log-in",
[Start Delta]<0,"Early Log-in",
"On-Time")