Forum Discussion

KellyLo's avatar
KellyLo
Frequent Visitor
2 years ago
Solved

Getting MIN Date based on two fiters

Hello - Hoping for some assistance. I have a column named "Source" and there are two values in this column. The table has two date columns, a date for one source and a date for the other. I need a calculation that will bring the MIN date for each. Example:

ID#1, Source = Email, Email Date = 5/1/2024, 5/2/2024, 5/3/2024.

ID#2, Source = Phone, Phone Date = 5/2/2024, 5/3/2024, 5/4/2024.

ID #3, Source = Phone, Phone Date = 4/1/2024, 5/1/2024, 5/5/2024

I need a calculation that would return this:

ID#1 = 5/1/2024

ID#2 = 5/2/2024

ID#3 = 4/1/2024

 

Is this possible?

 

 

  • kpost's avatar
    kpost
    2 years ago

    Okay so I created this fact table.

     

     

    Based on this fact table, I created this measure:

     

    Min_Date =
    VAR mindate_col1 = MIN([CreatedDate])
    VAR mindate_col2 = MIN([HasAttachmentDate])
    return
    IF(mindate_col1 <= mindate_col2, mindate_col1, mindate_col2)
     
    And was able to produce this visual:
     


  • Perfect! This group is so amazing. I have a meeting this afternoon and was a little concerned this wouldn't get solved in time. THANK YOU SO MUCH!!!

     

4 Replies

  • kpost's avatar
    kpost
    Icon for Solution Sage rankSolution Sage

    Could you include a screenshot of a table containing this example data?  It's a bit unclear exactly what values are in what columns and how they are formatted, from what you provided.

     

    • kpost's avatar
      kpost
      Icon for Solution Sage rankSolution Sage

      Okay so I created this fact table.

       

       

      Based on this fact table, I created this measure:

       

      Min_Date =
      VAR mindate_col1 = MIN([CreatedDate])
      VAR mindate_col2 = MIN([HasAttachmentDate])
      return
      IF(mindate_col1 <= mindate_col2, mindate_col1, mindate_col2)
       
      And was able to produce this visual:
       


      • KellyLo's avatar
        KellyLo
        Frequent Visitor

        Perfect! This group is so amazing. I have a meeting this afternoon and was a little concerned this wouldn't get solved in time. THANK YOU SO MUCH!!!