Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Multiple IF statements

HI There,

I'm trying to create a column with multiple if statements based on a due date.  I have created a column with todays date as Today's Date = now()

 

So my expression so far is which works fine is:

 

Due Status = if( [Today's Date].[Date]-[Due Date].[Date]>0,"Overdue",IF([Today's Date].[Date]-[Due Date].[Date]=0,"Due Today","Not Overdue"))
 
How do I add another if statement within the same formula where if Today's Date - Due Date is between 0 & 10, then return "Due in the next 10 days"

Thanks
Darren
  • Anonymous Well, you could do this but I would recommend using a SWITCH(TRUE() statement instead:

    Due Status = 
      if( 
        [Today's Date].[Date]-[Due Date].[Date]>0,
        "Overdue",
        IF(
          [Today's Date].[Date]-[Due Date].[Date]=0,
          "Due Today",
          IF(
            <third condition>,
            <if true>,
            "Not Overdue"
          )
        )
      )
    
    Due Status Alt = 
      SWITCH(TRUE(),
        ([Today's Date].[Date]-[Due Date].[Date])>0,"Overdue",
        ([Today's Date].[Date]-[Due Date].[Date])=0,"Due Today",
        <third condition>, <if true>,
        "Not Overdue"
      )

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Well, you could do this but I would recommend using a SWITCH(TRUE() statement instead:

    Due Status = 
      if( 
        [Today's Date].[Date]-[Due Date].[Date]>0,
        "Overdue",
        IF(
          [Today's Date].[Date]-[Due Date].[Date]=0,
          "Due Today",
          IF(
            <third condition>,
            <if true>,
            "Not Overdue"
          )
        )
      )
    
    Due Status Alt = 
      SWITCH(TRUE(),
        ([Today's Date].[Date]-[Due Date].[Date])>0,"Overdue",
        ([Today's Date].[Date]-[Due Date].[Date])=0,"Due Today",
        <third condition>, <if true>,
        "Not Overdue"
      )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Ok Cool - I'll try that - thanks heaps

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Here is my DAX:

       

      Step1 = IF(
                              DL_FYTD_SALES_AUM_VW[FYTD_CORP_MONTH_YEAR] == MAX(DL_FYTD_SALES_AUM_VW[FYTD_CORP_MONTH_YEAR]),"Current Month",
                             IF( DL_FYTD_SALES_AUM_VW[FYTD_CORP_MONTH_YEAR] == MAX(DL_FYTD_SALES_AUM_VW[FYTD_CORP_MONTH_YEAR])-1,"Prior Month", "History Month"))

       

      I got the below error:

      DAX comparison operations do not support comparing values of type Text with values of type Number. Consider using the VALUE or FORMAT function to convert one of the values.