Forum Discussion

juhoneyighot's avatar
juhoneyighot
Helper III
2 years ago
Solved

Join 2 table with additional calculated columns using dax

Hello! I need help on this. I have two tables that I need to join and create a calculated columns using DAX   1. Bookable Resource Table    Data source set-up is Date/Time so we will just put a c...
  • Anonymous's avatar
    Anonymous
    2 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 Team

     

    If 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!

  • lbendlin's avatar
    lbendlin
    2 years ago

    Start Time Status = SWITCH(TRUE(),
    [Start Delta]>10,"Late Log-in",
    [Start Delta]<0,"Early Log-in",
    "On-Time")