Forum Discussion

dgwilson's avatar
dgwilson
Resolver III
7 years ago
Solved

IF statement unexpected result evaluation

The goal here is to remove a very tiny piece of hard coding so that this measure never needs to be touched again. The measure returns a year to date sum on revenue. It works if the year is hard code...
  • dgwilson's avatar
    dgwilson
    7 years ago

    GilbertQ 

     

    Good news! I've been able to figure out that I had a fault in on of my measures.

     

     

    Fiscal Year TY = 
        var report_FY_Year = CALCULATE(MAX('Calendar'[Fiscal Year]), FILTER(ALL('Calendar'), 'Calendar'[Date] = [Report_Month]))
    RETURN
        report_FY_Year

     

    The Fiscal Year calculation did not have ALL('Calendar') in the filter. So when I was convinced that it was returning 2019... it was not necessarily in all cases as it worked through July thru June.

     

    This meant that when I used it in Revenue YTD the measure kept changing on me.

     

     

    _Revenue_YTD = 
        VAR reportMonth = [Report_Month]
      VAR fiscalYear = [Fiscal Year TY]
        VAR YTD_Revenue = CALCULATE(Data[_Revenue], DATESYTD('Calendar'[Date], "30 June"), FILTER(ALL('Calendar'), AND('Calendar'[Fiscal Year]=fiscalYear, 'Calendar'[Date] <= reportMonth)))
    RETURN
    YTD_Revenue

     

    This measure does give me the expected results now.

     

    - David