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
Anonymous
Not applicable

DAX Formula returning the Latest Date filtered by a AGREGATE Data Field

Hey guys! I'm new at developing Power BI Solutions and need help with some DAX Formula. Here is my case:

I have a graphic that shows the price of an item per time.

data1.JPG
I need to return the Latest Date of the lowest price.
I mean, in the example above, that price would be 14,19  and the Latest Date that item was bought with that price was 28/10/2015.

 

The result should be:

data2.jpg


Furthermore, I need to do the same thing with the higher value, wich is R$16.92.
I already tried Quick measure but didn´t work.

Best Regards.
Gustavo

 

 

2 ACCEPTED SOLUTIONS
PietroFarias
Resolver II
Resolver II

Hi!

 

The measure below retrieve the date from the lowest price of  table displayed.

 

Measure :=
VAR MinPrice =
    MIN ( tbPrice[Price] )
RETURN
    CALCULATE ( 
               LASTDATE ( tbPrice[DatePrice] ),
               tbPrice[Price] = MinPrice 
)

View solution in original post

Anonymous
Not applicable

Hey @PietroFarias, thanks for the quick response.

The DAX got me this following error:

"MdxScript(Model) (8, 16) Calculation error in measure 'Movement'[Latest Date of Lower Price]: A date column containing duplicate dates was specified in the call to function 'LASTDATE'. This is not supported.

View solution in original post

4 REPLIES 4
PietroFarias
Resolver II
Resolver II

Hi!

 

The measure below retrieve the date from the lowest price of  table displayed.

 

Measure :=
VAR MinPrice =
    MIN ( tbPrice[Price] )
RETURN
    CALCULATE ( 
               LASTDATE ( tbPrice[DatePrice] ),
               tbPrice[Price] = MinPrice 
)
Anonymous
Not applicable

Hey @PietroFarias, thanks for the quick response.

The DAX got me this following error:

"MdxScript(Model) (8, 16) Calculation error in measure 'Movement'[Latest Date of Lower Price]: A date column containing duplicate dates was specified in the call to function 'LASTDATE'. This is not supported.

Anonymous
Not applicable

@PietroFarias I replaced 'LASTDATE' for 'MAX' so it's working pretty well. Thanks for you help man!

Great!

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.