Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Matthew_Theis
Advocate II
Advocate II

Problems with LookupValue

Hello Everyone,

 

Thanks for the help in advance.  I'm trying to utilize LOOKUPVALUE to provide me with the previous weeks' price for any given PartNumber and Distributor.  I don't want to hardcode in a distributor name, as I have done here, but if I leave the line as follows:
'Octopus FindChipsExport'[Distributor],'Octopus FindChipsExport'[Distributor],

"I get an error "a table of multiple values was supplied where a single value was expected."

Below is what I can get returned when I hardcode TTI in as a distributor...it provides the previous weeks' price for both distributors.

image.png

 

I am hoping to be able to achieve a column that can read the Distributor and PartNumber and provide me the previous weeks' price.  For example, on 18/08/09 Arrow Electronics Previous Weeks Price should read $0.2791 while TTI would read $0.0000.

Also, if you can help me understand what DAX is doing that would be great.

 

Thanks,

Matthew

 

 

1 ACCEPTED SOLUTION

I was able to come up with a solution to my problem.  Here is the query that I used...

Previous Price =
CALCULATE(
SUM('Octopus FindChipsExport'[Price]),
FILTER(
ALLSELECTED('Octopus FindChipsExport'),
'Octopus FindChipsExport'[DateOfImport] = SELECTEDVALUE('Octopus FindChipsExport'[DateOfImport]) - 7
&& 'Octopus FindChipsExport'[Distributor] = SELECTEDVALUE('Octopus FindChipsExport'[Distributor])
&& 'Octopus FindChipsExport'[PartNumber] = SELECTEDVALUE('Octopus FindChipsExport'[PartNumber])
)
)

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Matthew_Theis,

 

>>a table of multiple values was supplied where a single value was expected

This error will appear when your formula return multiple values on one row. Please use calculate function to filter table and summary result.

Preview price =
CALCULATE (
    SUM ( Table[Price] ),
    FILTER (
        ALL ( Table ),
        Table[PartNumber] = EARLIER ( [PartNumber] )
            && Table[Distributor] = EARLIER ( [Distributor] )
            && Table[DateOfImport]
                = EARLIER ( [DateOfImport] ) - 7
    )
)

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

image.png

 

Hi @v-shex-msft thanks for the reply.  I tried your DAX and it appears that EARLIER isn't able to identify the previous row context, as can be seen by the error above.  

 

I did come up with something else that may work, much simplier.  

 

Prior Price =
CALCULATE(
           MAX('Octopus FindChipsExport'[Price]),
           'Octopus FindChipsExport'[DateOfImport]-7
)

Ideally I would be able to have this return blank for prices of 18/08/02 as there is no data to compare to prior to that date.  Are they downsides to this equation, should we be unable to get the one with EARLIER to work properly?

 

Thank you!

 

Matthew

I was able to come up with a solution to my problem.  Here is the query that I used...

Previous Price =
CALCULATE(
SUM('Octopus FindChipsExport'[Price]),
FILTER(
ALLSELECTED('Octopus FindChipsExport'),
'Octopus FindChipsExport'[DateOfImport] = SELECTEDVALUE('Octopus FindChipsExport'[DateOfImport]) - 7
&& 'Octopus FindChipsExport'[Distributor] = SELECTEDVALUE('Octopus FindChipsExport'[Distributor])
&& 'Octopus FindChipsExport'[PartNumber] = SELECTEDVALUE('Octopus FindChipsExport'[PartNumber])
)
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.