Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Lookupvalue will not return time value

Hi,

 

I've been working on this for six hours, so I thought I would try the community for an answer! I have Googled/lurked the forums to no avail. 

 

I have two tables of data: I'm trying to populate a column in one with data from the other using LOOKUPVALUE.

 

Table One has a list of specific events:

DateTruckJoinKeyEvent TypeTime of EventCarrying
01/01/2016RedRed42370Time Departed12:01:00 PMApples
01/01/2016BlueBlue42370Time Departed1:05:00 PMOranges
01/01/2016YellowYellow42370Time Departed7:33:00 AMBananas
01/01/2016RedRed42370Time Arrived2:53:00 AMBananas
01/01/2016BlueBlue42370Time Arrived4:32:00 PMBananas
01/01/2016YellowYellow42370Time Arrived9:32:00 AMOranges
02/01/2016YellowYellow42371Time Departed5:24:00 AMApples
02/01/2016RedRed42371Time Departed11:24:00 PMApples
02/01/2016BlueBlue42371Time Departed8:11:00 PMOranges
02/01/2016YellowYellow42371Time Arrived12:00:00 AMOranges
02/01/2016RedRed42371Time Arrived4:22:00 AMBananas
02/01/2016BlueBlue42371Time Arrived3:25:00 PMOranges

 

Here is Table 2, the one I'm trying to use LOOKUPVALUE with:

DateTruckJoinKeyTime DepartedTime Arrived
01/01/2016RedRed42370  
01/01/2016BlueBlue42370  
01/01/2016YellowYellow42370  
02/01/2016RedRed42371  
02/01/2016BlueBlue42371  
02/01/2016YellowYellow42371  

 

I am using LOOKUPVALUE with a unique column, "JoinKey" to populate with the values from Table 1. There is only one instance of departed and arrival times for each day and "truck".

Time Departed = LOOKUPVALUE(Table1[Time of Event],Table1[JoinKey],Table2[JoinKey],Table1[Event Type],"Time Departed")

However, I keep getting the error, "A table of multiple values was supplied where a single value was expected."

 

The "JoinKey" column for Table2 has unique values and I have built a many:1 relationship from Table 1 to it.  To test it, I have tried subsituting the "Time of Event" value in the formula with other columns, e.g. "Carrying", and it works fine. The LOOKUPVALUE returns the value from every other column except "Time of Event". 

 

Is LOOKUPVALUE not compatible with time values? I've tried formatting it to text and it still won't work. If I'm not making any sense please let me know... I think I've been staring at this for too long.

 

Any assistance you could provide would be greatly appreciated!

 

Thank you,

 

Kristen

  • Hi Kristen,

     

    You can use Query editor as well to solve this type of problem.

    Just few mouse clicks and you are done. Follow the screenshots for exact solution.

    Merge Table 2 and Table 1 as shown in the ScreenshotExpand the new column and select Event Type & Time of Event CheckboxesChange the data Type of the last column to Time and Rename both the columnsTime of the Event Column with new Data TypePivot the Column. Select the options shown in the screenshotAll done. TA....DA........

4 Replies

  • Sean's avatar
    Sean
    Community Champion

    Anonymous You need to have unique combinations of [JoinKey] and [Event Type]

     

    To test this create a COLUMN In Table 1 Create

    Column = Table1[JoinKey]&" - "&Table1[Event Type]

    Then create this MEASURE

    Transactions = COUNTROWS(Table1)

    Then create a Visualization Table with the Column and Transactions.

    If you see anything other than 1 for each column - that will be what's causing the problem!

    Basically the function will have more than 1 possible answer that meets your criteria.

    Hope this helps and makes sense! :smileyhappy:

     

     

    You can use the Visual Level Filters to => show Transactions more than 1 so you can identify the problem faster.

     

    EDIT: Just to clarify - my post was merely answering your question about the error message you get with the LOOKUPVALUE.

    I would personally also use with the Query Editor to shape your original dataset better.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much for the prompt reponse!

  • Hi Kristen,

     

    You can use Query editor as well to solve this type of problem.

    Just few mouse clicks and you are done. Follow the screenshots for exact solution.

    Merge Table 2 and Table 1 as shown in the ScreenshotExpand the new column and select Event Type & Time of Event CheckboxesChange the data Type of the last column to Time and Rename both the columnsTime of the Event Column with new Data TypePivot the Column. Select the options shown in the screenshotAll done. TA....DA........

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much for this!  I had tried merging queries but pivoting was completely new to me. Grateful to have learned something new.

       

      Thank you!