Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Unique column values

Hi 

 

I am trying to get a table wth cst and sales rep based on the last order date

 

so I have a table 

Customer #Sales RepLast order date
1018574tim9/21/2017
1018574alex9/22/2017
1017640dirk1/12/2018
1017640pit8/23/2017
1017640john10/24/2017
1020601kris1/11/2018
1020601michael12/15/2017
1015972Lisa1/11/2018
1015972carsten1/15/2018
1015972maria9/4/2017
1015972tom12/28/2017
1015981carsten11/13/2017
1015981niels1/15/2018
1020722jenny12/1/2017
1020722peter1/4/2018

 

 

and I would like to get a new table which will look like this

 

1018574alex
1017640dirk
1020601kris
1015972carsten
1015981niels
1020722peter

 

 

thank you 

 



  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    8 years ago

    Anonymous

     

    As a calculated column you could use

     

    Column =
    VAR MyMax =
        CALCULATE (
            MAX ( TableName[Last order date] ),
            ALLEXCEPT ( TableName, TableName[Customer #] )
        )
    RETURN
        CALCULATE (
            FIRSTNONBLANK ( TableName[Sales Rep], 1 ),
            FILTER (
                ALLEXCEPT ( TableName, TableName[Customer #] ),
                TableName[Last order date] = MyMax
            )
        )

12 Replies

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    Anonymous just create a dax measure do a LastDate = lastdate(datefield) and use the LastDate

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanx vanessafvg

       

      That doesnt work because i have multiple sales reps per customer. 

      Example customer

      1015970 was maintained by sales rep maria in sept 2017, by tom in december 2017, by lisa on the 11th of Jan and finaly by Tom on 15th of Jan 2018

       

      I would like to see only TOM

       

      Thats why i am trying to get a column where i will see the last date per customer and then use it in another column where i would liek to use if function or something like that.. 

       

      would be great if you can help me somehow becasue i am really strugeling here.. 

       

      thanx for your time

       

       

       

       

      • vanessafvg's avatar
        vanessafvg
        Community Champion

        Anonymous ok you need to  summarzie the table in my opinion

         

        summarizetable = SUMMARIZE(data,Data[Customer #], Data[Sales Rep], "Lastdate",  max(Data[Last order date]) )

         

        from the new table you should be abel to pull the last per record

         

         

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Anonymous

     

    It works when I use the sample data you have provided. See the pic below

     

    Could you show me a screenshot of your formula?

     

    or share the file via onedrive or googledrive