10 Replies Latest reply on Oct 11, 2018 11:43 AM by ShivaRam Chennapragada

    Cannot mix aggregate and non-aggregate in IF

    gxu

      Hi, I got this error message when trying to get the L3M of gross margin, see my calculation below:

       

      IF [Date] <= TODAY()

      AND

      (

      DATEDIFF('month',[Date],TODAY())=1

      or

      DATEDIFF('month',[Date],TODAY())=2

      or

      DATEDIFF('month',[Date],TODAY())=3

      )

      then [Gross Margin] END

       

      And the calculation for [Gross Margin]= SUM([Sales])-SUM([COGS])

       

      Can anyone help me fix the IF statement?