Forum Discussion

DeBIe's avatar
DeBIe
Post Partisan
3 years ago
Solved

Fix time intelligence measure

Hi all,

 

I am using a time intelligence measure to filter results for the current month, but I detected that it's not giving me the correct result. Since a while I also included data from previous years. Now it's also taking the result from April last year. I think because it merges the result under the name 'April'. 

 

Total Changes % CM = CALCULATE([Total Changes %],MONTH('Calendar'[Dates])=MONTH(TODAY()))

 
Any idea how to fix this? I thought replacing [Dates] for [YearMonth] but that did not work. I think I need to add extra intelligence that validates if it's the current year?

  • DeBIe ,because you are comparing month not month year

     

    refer

     

    MTD Today =
    var _min = eomonth(today(),-1)+1
    var _max = today()
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    LMTD Today=
    var _min = eomonth(today(),-2)+1
    var _max1 = today()
    var _max = date(year(_max1),month(_max1)-1, day(_max1))
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    LYMTD Today =
    var _min = eomonth(today(),-13)+1
    var _max1 = today()-1
    var _max = date(year(_max1)-1,month(_max1), day(_max1))
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    MTD Yesterday =
    var _max = today() -1
    var _min = eomonth(_max,-1)+1
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    This Month Today =
    var _min = eomonth(today(),-1)+1
    var _max = eomonth(today(),0)
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    Last Month Today =
    var _min = eomonth(today(),-2)+1
    var _max = eomonth(today(),-1)
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    Same Month Last Year Today =
    var _min = eomonth(today(),-13)+1
    var _max = eomonth(today(),-12)
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

     

1 Reply

  • DeBIe ,because you are comparing month not month year

     

    refer

     

    MTD Today =
    var _min = eomonth(today(),-1)+1
    var _max = today()
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    LMTD Today=
    var _min = eomonth(today(),-2)+1
    var _max1 = today()
    var _max = date(year(_max1),month(_max1)-1, day(_max1))
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    LYMTD Today =
    var _min = eomonth(today(),-13)+1
    var _max1 = today()-1
    var _max = date(year(_max1)-1,month(_max1), day(_max1))
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    MTD Yesterday =
    var _max = today() -1
    var _min = eomonth(_max,-1)+1
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    This Month Today =
    var _min = eomonth(today(),-1)+1
    var _max = eomonth(today(),0)
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    Last Month Today =
    var _min = eomonth(today(),-2)+1
    var _max = eomonth(today(),-1)
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    Same Month Last Year Today =
    var _min = eomonth(today(),-13)+1
    var _max = eomonth(today(),-12)
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))