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
LotteLaugesen
Helper V
Helper V

Find first date in table where date greater than invoice date

Hi

How do I find max Valid from in the Interest table where Invoice date >= Valid from?
Invoice date = 2021-11-16 and I want to get row 2, Valid from 2021-11-15
Interest table

LotteLaugesen_0-1645529490107.png

Any ideas?

 

Lotte

 

1 ACCEPTED SOLUTION

Try

Intrest Lookup Date =
MAXX (
    FILTER ( ALL ( Table ), Table[Valid from] <= MAX ( Invoice[Invoice Date] ) ),
    Table[Valid from]
)

View solution in original post

12 REPLIES 12
tamerj1
Super User
Super User

Hi @LotteLaugesen 
You can use

Intrest Lookup Date =
MAXX (
    FILTER ( Table, Table[Valid from] <= MAX ( Invoice[Invoice Date] ) ),
    Table[Valid from]
)

Hi tamerj1

Unfortunately I then get 2021-12-20 in return and not 201-11-15

But thanks anyway

 

Try

Intrest Lookup Date =
MAXX (
    FILTER ( ALL ( Table ), Table[Valid from] <= MAX ( Invoice[Invoice Date] ) ),
    Table[Valid from]
)

Same result - but thanks for trying 👍

Hi @LotteLaugesen 
I'm getting correct results. See the screen shot. But I think it depends on your data model and relationships. Most probably you have a connected date table. Can you please send a screen shot of your data model with the relationships?
Thanks and have a nice day! 
1.png

Here is my datamodel and contents of NFV Interest Rates:

LotteLaugesen_0-1645607969662.png
LotteLaugesen_4-1645608817516.png

And this is the calculation and result

LotteLaugesen_1-1645608309265.png

LotteLaugesen_3-1645608383219.png

Thanks for your time 🙂

 

 

@LotteLaugesen 
Are you sure invoice date is of date data type? It looks like it is of text data type 🙂

I'm wondering why it looks like that, too...

But look here:

LotteLaugesen_0-1645612867828.png

 

Check the data source from power query. Or if you don't mind can you please a sample data version of the file?

Sorry about all this - I had made the calculation as a new column in the Merge ARAP and SCF table and not as a new measure 🙈  So after changing that it works perfectly
Thanks for all you time  

amitchandak
Super User
Super User

@LotteLaugesen , You can create a new measure

 

calculate(sum(Table[Intrest]), filter(Table, Table[Valid from] >= max(Invoice[Invoice Date]) ) )

 

 

Unfortunately it doesn't work. I get the sum of all interest 

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.

Top Solution Authors