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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
CD1
Frequent Visitor

Lookup value measure with specific range

Hi,

 

I am trying to create a measure based on different ranges of sums for the same parameter from a different table...

 

In simplified terms, these are the tables I have:

 

Master Tables (from databases):

 

1) Receivables table:

- Columns: month, clients, receivables 

Ex: 

MONTH

CLIENT

RECEIVABLES

July 2017

A

$100,000

August 2017

B

$150,000

August 2017

A

$200,000

 

 

*There are instances where there are several lines for the same client within the same month with different receivables values

 

2) Invoices table: 

- Columns: month, clients, sales

Ex:

MONTH

CLIENT

INVOICES/SALES

July 2017

A

$15,000

August 2017

B

$10,000

 

 

Created Summary Table from Master Tables:

 

o   Columns: Customer, YTD Receivables, YTD Sales

o   Ex:

CLIENT

YTD R

YTD S

A

$300,000

$15,000

B

$200,000

$10,000

 

Essentially what I am trying to achieve is to calculate the # days overdue for invoices. This formula is quite long and contains many 'IFs'. I am able to achieve this calculation based on the months alone but not on months AND clients. 

 

 Simplified formula: Total Receivables/Total Invoices for current month * #days (in month)

 Issue: Require the sum of invoices for the same client in previous month(s)

--> How can I do a ‘lookupvalue’ of a sum (in invoices table) for a specific range? Is this possible?

 

(Relationships: There is a 'Calendar' table linked to my 'Receivables' and 'Invoices' tables)

 

I have added a 'rank' column linked to my 'months' to substitute 'month no.' for my company's budget year. Next, when trying to pull the sum from a previous month I used 'Rank-1' in my 'lookupvalue' formula. The issue is that I need my measure to filter on both the client and specific month and the result of the "previous month's invoices sum" is an error message or it gives me the total invoices for all months and clients. Not sure if this is clear enough... 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @CD1,

 

Please try below formula.

Rank =
CALCULATE (
    COUNTROWS ( 'Table2' ),
    FILTER (
        ALL ( Table2 ),
        'Table2'[Client] = EARLIER ( Table2[Client] )
            && 'Table2'[Month] < EARLIER ( 'Table2'[Month] )
    )
)
    + 1


Previous month Invoice =
LOOKUPVALUE (
    Table2[Invoice],
    Table2[Client], Table2[Client],
    Table2[Rank], Table2[Rank] - 1
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @CD1,

 

Please try below formula.

Rank =
CALCULATE (
    COUNTROWS ( 'Table2' ),
    FILTER (
        ALL ( Table2 ),
        'Table2'[Client] = EARLIER ( Table2[Client] )
            && 'Table2'[Month] < EARLIER ( 'Table2'[Month] )
    )
)
    + 1


Previous month Invoice =
LOOKUPVALUE (
    Table2[Invoice],
    Table2[Client], Table2[Client],
    Table2[Rank], Table2[Rank] - 1
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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