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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Krisvenkata11
Frequent Visitor

Error with Lookuptable "A table of multiple values are supplied"

I am trying to prorate the data based on the current month data(cut off date is April 14). I need to take cutoff value which is on April14th and prorate it to all days in the month of May

I am getting a error "A table of multiple values are supplied" while executing below

 

LatestColumn = LASTDATE(SUMMARIZE(FILTER('Sheet1 (2)', 'Sheet1 (2)'[Work Item] <> 0),'Sheet1 (2)'[Date]))
----------------------------------------
Findval=
var k = FIRSTNONBLANK('Sheet1 (2)'[LatestColumn], 1)
Var X= LOOKUPVALUE('Table 1 (Sheet1)'[Sales], 'Table 1 (Sheet1)'[Date], k
 
my current input is:
 
DateSales
4/1/202210
4/2/20225
4/3/20224
4/4/20226
4/5/20223
4/6/20226
4/7/20225
4/8/202222
4/8/202222
4/9/202220
4/10/202222
4/11/202224
4/12/202223
4/13/202225
4/14/202220
4/14/20220
4/15/20220
4/16/20220
4/17/20220
4/18/20220
4/19/20220
4/20/20220
4/21/20220
4/22/20220
4/23/20220
4/24/20220
4/25/20220
4/26/20220
4/27/20220
4/28/20220
4/29/20220
4/30/20220
5/1/20220
5/2/20220
5/3/20220
5/4/20220
5/5/20220
5/6/20220
5/7/20220
5/8/20220
5/9/20220
  and expected output ise
DateSales
4/1/202210
4/2/20225
4/3/20224
4/4/20226
4/5/20223
4/6/20226
4/7/20225
4/8/202222
4/8/202222
4/9/202220
4/10/202222
4/11/202224
4/12/202223
4/13/202225
4/14/202220
4/14/20220
4/15/20220
4/16/20220
4/17/20220
4/18/20220
4/19/20220
4/20/20220
4/21/20220
4/22/20220
4/23/20220
4/24/20220
4/25/20220
4/26/20220
4/27/20220
4/28/20220
4/29/20220
4/30/20220
5/1/202220
5/2/202220
5/3/202220
5/4/202220
5/5/202220
5/6/202220
5/7/202220
5/8/202220
 
 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@Krisvenkata11 
Following to our messages, please refer to sample file with the updated solution https://www.dropbox.com/t/ChEaKYhinqk5wlVK

The number of working days shall be within a separate dimension table as shown in the pictures. I believe this is an easy job however please let me know if you need any help on that. 
Then adjust your model as shown in the screenshot and update the code as follows

1.png2.png3.png

 

Sales Amount = 
VAR CurretDate =
    MAX ( 'Date'[Date] )
VAR CurrentWeekDay =
    WEEKDAY ( CurretDate )
VAR WorkingDays =
    SELECTEDVALUE ( 'Working Days'[Cus_Bus_Days] )
VAR LastDateWithSales =
    CALCULATE ( MAX ( Sales[Date] ), REMOVEFILTERS ( 'Date' ) )
VAR CurrentSales =
    SUM ( Sales[Sales] )
VAR LastDateSales =
    CALCULATE (
        SUM ( Sales[Sales] ),
        Sales[Date] = LastDateWithSales,
        REMOVEFILTERS ( 'Date' )
    )
VAR Result =
    SUMX (
        VALUES ( 'Date'[Date] ),
        CALCULATE (
            IF (
                CurretDate > LastDateWithSales,
                IF ( 
                    CurretDate <= EOMONTH ( LastDateWithSales, 0 )
                        || DIVIDE ( CurrentWeekDay * 6, WorkingDays ) = 1, 
                    0, 
                    LastDateSales 
                ),
                CurrentSales
            )
        )
    )
RETURN
    Result

 

4.png5.png

I hope this answers your query 

View solution in original post

10 REPLIES 10
tamerj1
Super User
Super User

@Krisvenkata11 
Following to our messages, please refer to sample file with the updated solution https://www.dropbox.com/t/ChEaKYhinqk5wlVK

The number of working days shall be within a separate dimension table as shown in the pictures. I believe this is an easy job however please let me know if you need any help on that. 
Then adjust your model as shown in the screenshot and update the code as follows

1.png2.png3.png

 

Sales Amount = 
VAR CurretDate =
    MAX ( 'Date'[Date] )
VAR CurrentWeekDay =
    WEEKDAY ( CurretDate )
VAR WorkingDays =
    SELECTEDVALUE ( 'Working Days'[Cus_Bus_Days] )
VAR LastDateWithSales =
    CALCULATE ( MAX ( Sales[Date] ), REMOVEFILTERS ( 'Date' ) )
VAR CurrentSales =
    SUM ( Sales[Sales] )
VAR LastDateSales =
    CALCULATE (
        SUM ( Sales[Sales] ),
        Sales[Date] = LastDateWithSales,
        REMOVEFILTERS ( 'Date' )
    )
VAR Result =
    SUMX (
        VALUES ( 'Date'[Date] ),
        CALCULATE (
            IF (
                CurretDate > LastDateWithSales,
                IF ( 
                    CurretDate <= EOMONTH ( LastDateWithSales, 0 )
                        || DIVIDE ( CurrentWeekDay * 6, WorkingDays ) = 1, 
                    0, 
                    LastDateSales 
                ),
                CurrentSales
            )
        )
    )
RETURN
    Result

 

4.png5.png

I hope this answers your query 

tamerj1
Super User
Super User

@Krisvenkata11 
Following to our messages, please refer to sample file with the updated solution https://www.dropbox.com/t/ChEaKYhinqk5wlVK

The number of working days shall be within a separate dimension table as shown in the pictures. I believe this is an easy job however please let me know if you need any help on that. 
Then adjust your model as shown in the screenshot and update the code as follows

1.png2.png3.png

Sales Amount = 
VAR CurretDate =
    MAX ( 'Date'[Date] )
VAR CurrentWeekDay =
    WEEKDAY ( CurretDate )
VAR WorkingDays =
    SELECTEDVALUE ( 'Working Days'[Cus_Bus_Days] )
VAR LastDateWithSales =
    CALCULATE ( MAX ( Sales[Date] ), REMOVEFILTERS ( 'Date' ) )
VAR CurrentSales =
    SUM ( Sales[Sales] )
VAR LastDateSales =
    CALCULATE (
        SUM ( Sales[Sales] ),
        Sales[Date] = LastDateWithSales,
        REMOVEFILTERS ( 'Date' )
    )
VAR Result =
    SUMX (
        VALUES ( 'Date'[Date] ),
        CALCULATE (
            IF (
                CurretDate > LastDateWithSales,
                IF ( 
                    CurretDate <= EOMONTH ( LastDateWithSales, 0 )
                        || DIVIDE ( CurrentWeekDay * 6, WorkingDays ) = 1, 
                    0, 
                    LastDateSales 
                ),
                CurrentSales
            )
        )
    )
RETURN
    Result

4.png5.png

I hope this answers your query 

tamerj1
Super User
Super User

@Krisvenkata11 
Here is a sample file with the solution 

You cannot add rows to an existing table in power bi but you can add columns. What you call date table can actually be your new sales table. This is one option. Other option is to rely on a table visual and utilize measures.

 

  • Option 1

https://www.dropbox.com/t/IwoZ27YoMQBMbuyQ

Here I suppose you have only the Sales table. Then we can start creating a new sales table that contains all the dates up to the end of the year. 

 

All Dates Sales = CALENDAR ( MIN ( Sales[Date] ), DATE ( YEAR ( MAX ( Sales[Date] ) ), 12, 31 ) )

 

3.png

Then create one to many relationship with the original sales table

4.png

Now you can add a new column in the new table to retrieve sales for respective dates and last date sales for future dates. Here I prefer to use SUMX in order to aggregated all the sales of a day in case you have multiple sales in on day

 

Sales = 
VAR CurrentDateSales =
    SUMX ( RELATEDTABLE ( Sales ), Sales[Sales] )
VAR TableWithSales =
    FILTER ( Sales, Sales[Sales] > 0 )
VAR LastDateWithSales =
    MAXX ( TableWithSales, Sales[Date] )
VAR LastDateSales =
    SUMX (
        FILTER ( TableWithSales, Sales[Date] = LastDateWithSales ),
        Sales[Sales]
    )
RETURN
    IF (
        'All Dates Sales'[Date] > LastDateWithSales,
        LastDateSales,
        CurrentDateSales
    )

 

1.png

 

  • Option 2

https://www.dropbox.com/t/j5GqpHeLUJqydJpV

Create The Date table using the same code as above. Then creating one to many relationship between the two tables. Then write a Measure 

 

Sales Amount = 
VAR CurretDate =
    MAX ( 'Date'[Date] )
VAR LastDateWithSales =
    CALCULATE ( MAX ( Sales[Date] ), REMOVEFILTERS ( 'Date' ) )
VAR CurrentSales =
    SUM ( Sales[Sales] )
VAR LastDateSales = 
    CALCULATE ( SUM ( Sales[Sales] ), Sales[Date] = LastDateWithSales, REMOVEFILTERS ( 'Date' ) )
RETURN
    SUMX ( 
        VALUES ( 'Date'[Date] ),
        CALCULATE ( 
            IF ( 
                CurretDate > LastDateWithSales,
                LastDateSales,
                CurrentSales
            )
        )
    )

 

In a table visual place the Date[Date] (Do not summarize) and then place the measure

5.png

Please let me know if you have any doubt or any question.

tamerj1
Super User
Super User

Hi @Krisvenkata11 

Do you actually have the date Apr. 14th twice? Are you trying to create a neasure or a calculated column?

Yes, i have the Apr 14 data twice. I am creating a column.

Apr 14  - 20

Aprl 14 - 0

 

Single value works fine. My challenge how to handle above?

@Krisvenkata11 

You can achieve than in many ways. One way to start with retrieving the last date with sales

VAR TableWithSales =
FILTER ( Table, Table[Sales] > 0 )

VAR LastDateWithSales = 

MAXX ( TableWithSales, Table[Date] )

then retrive the sales value

VAR LastDateSales =
MAXX ( FILTER ( TableWithSales, Table[Date]  = LastDateWithSales ), Table[Sales] )


then RETURN

IF ( Table[Sales] = 0, LastDateSales, Table[Sales] )

 

Thanks a ton, this will work if i have everything in one table but my issue is:

I have a table called 'DatesAll' which contains all the dates from Jan1 st to Dec 31st 2022

I am joining it with sales table which is having the DateSale Column till April 14th(cut off Date)

When i am using Maxx function it is not allowing me to refer the Date column in DatesAll table and only showing the Measures of DatesAll table not columns. Is cross table reference not allowed in Maxx function although both are joined?

 

 

@Krisvenkata11 

Can you please share some screenshots?

Krisvenkata11_0-1650135743766.png

Sales Table Data

Krisvenkata11_1-1650135803392.png

Date Table( from Jan 1st to 31st Dec)

Krisvenkata11_2-1650135877399.png

Below is not taking column  from DateTable and expecting only SalesTables Columns
VAR LastDateWithSales = MAXX ( TableWithSales, 'SalesTable'[Date] )
 
 

 

 

Hi @Krisvenkata11 

here is the final solution based on option 2

Sales Amount =
VAR CurretDate =
    MAX ( 'Date'[Date] )
VAR LastDateWithSales =
    CALCULATE ( MAX ( Sales[Date] ), REMOVEFILTERS ( 'Date' ) )
VAR CurrentSales =
    SUM ( Sales[Sales] )
VAR LastDateSales =
    CALCULATE (
        SUM ( Sales[Sales] ),
        Sales[Date] = LastDateWithSales,
        REMOVEFILTERS ( 'Date' )
    )
RETURN
    SUMX (
        VALUES ( 'Date'[Date] ),
        CALCULATE (
            IF (
                CurretDate > LastDateWithSales,
                IF ( CurretDate <= EOMONTH ( LastDateWithSales, 0 ), 0, LastDateSales ),
                CurrentSales
            )
        )
    )

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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