Forum Discussion

BhagatRansi's avatar
BhagatRansi
Frequent Visitor
5 years ago
Solved

MaxDate per Value

Hi everyone,

 

I am bit in a challenge. I am receiving a table where measures a different frequencies. Some are delivered on a monthly base and some on random dates. The client like to see the most current value with the according date as an informtional attribute with it.

 

Following an example of the data structure:

 

DateOrganisationValue AValue BValue CValue D
01.01.2021

West

50205060
01.02.2021

West

30 5060
01.03.2021

West

30505060
01.04.2021

West

30 5060

 

Result:

 

For Value A,C & D the MaxDate is 01.04.2021 with the Value A=30; C=50 & D=60

 

For Value B the MaxDate is 01.03.2021 with the Value B=50

 

How can I create a measure showing me exact these values and also map the accoring attributes like Date and Organisation to it?

 

Looking forward to hear from you

 

Thanks in advance for any idea

 

  • BhagatRansi 

    1. select date and orgnization column and unpivot other columns in PQ

    2. create two measures

    maxdate = MAX('Table'[Date])
    
    Measure = MAXX(FILTER('Table','Table'[Attribute]=max('Table'[Attribute])&&'Table'[Date]=max('Table'[Date])),'Table'[Value])

     please see the attachment below

6 Replies

  • BhagatRansi 

    1. select date and orgnization column and unpivot other columns in PQ

    2. create two measures

    maxdate = MAX('Table'[Date])
    
    Measure = MAXX(FILTER('Table','Table'[Attribute]=max('Table'[Attribute])&&'Table'[Date]=max('Table'[Date])),'Table'[Value])

     please see the attachment below

    • BhagatRansi's avatar
      BhagatRansi
      Frequent Visitor

      Hi Ryan_mayu,

       

      I still need your support the solution works so far but now I am facing the issue that when summarizing the values I am getting the Max Value of the analyzed dimension.

      See in your example Value D = 60 and the Total result is also 60.

       

      Is there a way to sum or to calculate the average of the values? In our case Total =47,5

       

      • ryan_mayu's avatar
        ryan_mayu
        Super User

        BhagatRansi 

        you can create another measure

        Measure 2 = AVERAGEX(VALUES('Table'[Attribute]),[Measure])

  • selimovd's avatar
    selimovd
    Most Valuable Professional

    Hey BhagatRansi ,

     

    I guess you need anyway a new measure for each Value.

    The following should work:

    Last Value A = CALCULATE( SUM( myTable[Value A], myTable[Date] = MAX( myTable[Date] ) )

     

    Let me know if that works for you.

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     
    • BhagatRansi's avatar
      BhagatRansi
      Frequent Visitor

      Thanks for your reply this solution does not work as MAX cannot be used as filter expression in the Calculate formula