Forum Discussion

Vinothsusai's avatar
Vinothsusai
Helper III
5 years ago
Solved

Comparision graph issue (Current Year Nov and Dec months data dislaying from Previous year data)

Hello, I faced a issue on graph Cout column N and N-1 comparision that displays current year Nov and Dec months data is displaying from previous year.   Here my table(filtered only for 2020 ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Vinothsusai ,

     

    The reason for the error may be because your dax function uses "var date1=MAX(msdyn_actuals[msdyn_documentdate])".

     

    It will filter out the maximum date. The maximum date of November and December is the data of 2019, so your Current Year measure will return the data for 2019 in November and December.

     

    Below is my solution.

     

    1.Create a new table using DAX.

    Table = DISTINCT(SELECTCOLUMNS('msdyn_actuals',"Year",YEAR([Date])))

     

    2.Measures are as follows.

    Current Year = 
    var date1=
    SELECTEDVALUE('Table'[Year]) return
    CALCULATE (
    [Measure Total of type Cout],
    FILTER(msdyn_actuals, [year] = date1))
    Last Year = 
    var date1=
    SELECTEDVALUE('Table'[Year])
    RETURN
    CALCULATE (
    [Measure Total of type Cout],
    FILTER(msdyn_actuals, YEAR(msdyn_actuals[Date]) = date1-1))

     

     

     

    You can check more details from here.

     

     

     

    Best Regards,

    Stephen Tao

     

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