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
phjz
Frequent Visitor

Forcing LOOKUPVALUE to return only one value

Hey guys,

 

I thought I had a good approach for a formula, but in some cases I get this error message "A table of multiple values was supplied where a single value was expected". Here's what I need:

 

There is a table with Product names like this:

Product nameStart Date
A101.01.2020
B101.07.2021
C101.08.2022
A201.09.2020

 

And another table with something like sales:

VOLProduct CategorySales Date
3A07.02.2020
1A08.02.2020
6A07.09.2020
3A09.02.2020
3A10.09.2020
4B01.07.2021

 

Please note: The tables are not directly connected, but through another table so that A1, A2, ... belong to A.

 

What I want Power BI to do is to look for the maximum VOL and return the sum for the following 6 days. But first, he has to check if the volume of product category A belongs to A1 or A2, which I did with DATESBETWEEN Min(Start Date) and Min(Start Date)+60 days.

 

I tried this formula:

VOL_max =
CALCULATE (
    SUM ( 'Sales'[VOL] ),
        DATESBETWEEN(Sales[Sales Date],LOOKUPVALUE(Sales[Sales Date],'Sales'[VOL],CALCULATE(max(Sales[VOL]),DATESBETWEEN(Sales[Sales Date],min('Products'[Start Date]),min('Products'[Start Date])+60))),LOOKUPVALUE(Sales[Sales Date],Sales[VOL],CALCULATE(max(Sales[VOL]),DATESBETWEEN(Sales[Sales Date],min('Products'[Start Date]),min('Products'[Start Date])+60)))+6))
 
As I said, this doesn't work when there is no unique maximum volume because LOOKUPVALUE returns this multiple values. For me, it would be perfect, when Power BI would go with the first maximum by date. Do you have any idea how to fix this?
0 REPLIES 0

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.