Forum Discussion

exodeexo's avatar
exodeexo
New Member
8 years ago
Solved

max date conditional

Hi guys!!

 

I'd like to create a column (called "MAX_DATE") where I identify the max date in two specific process (PHTM & PHTS) per campaign. If these processes doesn't exist in the campaign, I'd like to asign a null. If one of them exist (PHTM or PHTS), the max_date should be the latest date. As you could see, you could have more than 1 row per campaign and process.

 

AreaProcessStart SequenceCampaign IDMAX_DATE
WHCOD29/07/2015136411null
WHPREP30/07/2015136411null
WHPREP30/07/2015135871null
PRODUCTDESC_IT28/08/2015135871null
WHPREP30/07/201513641113/10/2015
PRODUCTDESC_IT19/08/201513641113/10/2015
PHOTOPHTM13/10/201513641113/10/2015
PHOTOPHTS14/10/201513641114/10/2015
WHPREP19/10/201512786123/10/2015
PHOTOPHTM23/10/201512786123/10/2015
RETOUCHBR2414/10/201512786123/10/2015
RETOUCHPROD14/10/201512786123/10/2015
PHOTOPHTS13/10/201512786123/10/2015
PRODUCTDESC_IT21/10/201512786123/10/2015
PRODUCTUPDATA_IT15/10/201512786123/10/2015
PRODUCTUPDATA_IT19/10/201512786123/10/2015
PHOTOPHTM21/10/201512786123/10/2015

 

I've tried with the following formula, but the result is incorrect because all the campaign ID has date (this is impossible because there are some campaigns without process equals to PHTM or PHTS):

 

 

MAX_DATE = CALCULATE(MAX(Sequencer[Start Sequence].[Date]);Sequencer[Campaign ID];Sequencer[Process]="PHTS";Sequencer[Process]="PHTM")

 

Could you please help me?

 

Many thanks!!

 

Ivann

 

  • Phil_Seamark's avatar
    Phil_Seamark
    8 years ago

    HI exodeexo

     

    Please try this calculated column

     

    New Column = 
        MAXX(
            FILTER(
                'Sequencer',
                'Sequencer'[Process] IN {"PHTS","PHTM"} &&
                'Sequencer'[Campaign ID] = EARLIER('Sequencer'[Campaign ID]) 
                ),
                'Sequencer'[Start Sequence])

11 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Microsoft Employee

    Hi exodeexo

     

    Happy to help.  Can you please post what your expected result would look like for this sample dataset?

     

    This will help clarify your request :)

    • exodeexo's avatar
      exodeexo
      New Member

      Hi Phil_Seamark!! Thanks for helping me. 

       

      My expected result for this sample is the last column on your right.

       

        MAX DATE
      null
      null
      null
      null
      13/10/2015
      13/10/2015
      13/10/2015
      14/10/2015
      23/10/2015
      23/10/2015
      23/10/2015
      23/10/2015
      23/10/2015
      23/10/2015
      23/10/2015
      23/10/2015
      23/10/2015

       

      Many thanks! 

      • Phil_Seamark's avatar
        Phil_Seamark
        Microsoft Employee

        HI exodeexo

         

        Why are the top two rows NULL, when there are other rows for 136411 further down?