Forum Discussion

artfulmunkeey's avatar
5 years ago
Solved

Help with LOOKUP?

Hi all, I am relatively new and struggling with what I believe should be quite straightforward, but no end of tutorials seem to be helping me as I get various syntax errors 😕

 

I have two tables: Planned Hours sorted by project and date, and HoursBooked, also sorted by project and date (in realtiy this table also contains resourcecodes and projectcode, but for simplicity I have grouped by project for now).

 

HoursBooked
ProjectCodeTimeByDayHoursBooked
3000101/01/202050
3000101/02/2020100
3000101/04/2020150
3000101/07/202075
3000201/02/2020100
3000201/03/2020200
3000201/06/2020150
3000301/01/202050
3000301/04/202075
3000301/05/202025

 

PlannedHours
ProjectNameTimeByDayPlannedHours
3000101/01/202050
3000101/02/2020100
3000101/03/2020100
3000101/04/2020100
3000101/05/2020100
3000101/06/2020100
3000101/07/2020100
3000101/08/202050
3000101/09/2020100
3000101/10/2020150
3000101/11/202050
3000101/12/2020100
3000201/01/202050
3000201/02/2020100
3000201/03/2020150
3000201/04/202050
3000201/05/2020100
3000201/06/2020100
3000201/07/2020100
3000201/08/2020100
3000201/09/2020100
3000201/10/2020100
3000201/11/202050
3000201/12/202050
3000301/01/2020100
3000301/02/2020100
3000301/03/2020100
3000301/04/2020100
3000301/05/2020100
3000301/06/2020100
3000301/07/2020100
3000301/08/202050
3000301/09/202050
3000301/10/2020100
3000301/11/2020100
3000301/12/2020150

 

I am attempting to lookup the actual hours based on project ID, and match it to the planned hours by month in the original table.

 

Something like the following, so that I can then calculate remaining hours.

 

Merged Table (LOOKUP)
ProjectNameTimeByDayPlannedHoursHoursBooked
3000101/01/20205050
3000101/02/2020100100
3000101/03/20201000
3000101/04/2020100150
3000101/05/20201000
3000101/06/20201000
3000101/07/202010075
3000101/08/2020500
3000101/09/2020100 
3000101/10/2020150 
3000101/11/202050 
3000101/12/2020100 
3000201/01/2020500
3000201/02/2020100100
3000201/03/2020150200
3000201/04/2020500
3000201/05/20201000
3000201/06/2020100150
3000201/07/20201000
3000201/08/20201000
3000201/09/2020100 
3000201/10/2020100 
3000201/11/202050 
3000201/12/202050 
3000301/01/202010050
3000301/02/20201000
3000301/03/20201000
3000301/04/202010075
3000301/05/202010025
3000301/06/20201000
3000301/07/20201000
3000301/08/2020500
3000301/09/202050 
3000301/10/2020100 
3000301/11/2020100 
3000301/12/2020150 

 

RemainingHours
ProjectTotalPlannedHoursTotalHoursBookedRemainingHours
300011100375725
300021050450600
3000311501501000

 

Any help would be greatly appreciated, thanks!

  • Hi artfulmunkeey 

     

    Believe the best option is to create two dimension tables a project code and a calendar. Then make relationship between these two tables and the other two:

    Now create the following measures:

    HourBooked = SUM('Hours Booked'[HoursBooked])
    
    HoursPlanned = SUM(HourPlanned[PlannedHours])
    
    RemainingHours = [HoursPlanned] - [HourBooked]

     

    Now if you use the calendar and the projects table in your visualizations alongside with your dimension tables you can create the calculations in any way needed:

     

    Check PBIX file attach.

3 Replies

  • Hi artfulmunkeey 

     

    Believe the best option is to create two dimension tables a project code and a calendar. Then make relationship between these two tables and the other two:

    Now create the following measures:

    HourBooked = SUM('Hours Booked'[HoursBooked])
    
    HoursPlanned = SUM(HourPlanned[PlannedHours])
    
    RemainingHours = [HoursPlanned] - [HourBooked]

     

    Now if you use the calendar and the projects table in your visualizations alongside with your dimension tables you can create the calculations in any way needed:

     

    Check PBIX file attach.

  • v-diye-msft's avatar
    v-diye-msft
    Community Support

    Hi artfulmunkeey 

     

    If the above posts help, please kindly mark it as a answer to help others find it more quickly. thanks!

    If not, please kindly elaborate more.