Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Query prices for certain ID at maximum date

Hi community!

I am trying to build a measure to set a query for the prices [Cotacao] for the ID product [ID_FW]=21, [Validade]=1, in every segment[Prazo], for the last/max date [Data_Cotacao].

 

 

I am using this DAX formula:

calculate(average(Spot_FW[Cotacao]),LASTDATE(Spot_FW[Data_Cotacao]),filter(Spot_FW,Spot_FW[ID_FW]=21 && Spot_FW[Validade]=1))
 
The outcome should be in a line graph, the measure in Values, the [Prazo] in axis, as stated below:
However there are many segments [Prazo] that for the last date (25-05-2021) have [Validade]=0, though should not be in the graph (image: yellow signal). 
 
Any tip for what am I doing wrong?
 
Thanks in advance.
 
Cheers,
 

6 Replies

  • Kumail's avatar
    Kumail
    Impactful Individual

    Hello Anonymous 

     

    You can update the formula to 

     

    MAxDateUpdate = 
    CALCULATE(AVERAGE(data[Cotacao]), data[ID_FW]=21, data[Validade]=1, LASTDATE(data[Data_Cotacao]))

     

    Let me know if this helps. 

     

    Regards

    Kumail Raza

    • Anonymous's avatar
      Anonymous
      Not applicable

      No Kumail , unfortunately I still have [Prazo] form another dates.

      • Kumail's avatar
        Kumail
        Impactful Individual

        Anonymous 

         

        Can you send screenshots of the error here.

         

        Regards

        Kumail Raza