cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

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
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

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
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

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

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

Great!

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors