Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Current year blank values

In data there is a year 2021 only. i am trying to do analysis last and current year  Current 2022 year is going .. and when i try this measure this shows that    current year sales 0 last year sa...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  Anonymous ,

    I created some data:

    2020.1.1 – 2021.12.31

    Here are the steps you can follow:

    1. Create measure.

    last year sales =
    var _maxdate=
    MAXX(ALL('Table'),[Date])
    return
    IF(
    SUMX(FILTER(ALL('Table'),
    YEAR('Table'[Date])=YEAR(_maxdate)-1),[Column])=BLANK(),0)
    current year =
    var _maxdate=
    MAXX(ALL('Table'),[Date])
    return
    SUMX(FILTER(ALL('Table'),
    YEAR('Table'[Date])=YEAR(_maxdate)),[Column])
    
    

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly