Forum Discussion

Parihar1980's avatar
Parihar1980
Icon for Helper II rankHelper II
8 years ago

Sales over the year with Dynamic year value

Hello Friends , 

I am working on tablura model for a requrement where I have to show sales for Last 5 year in a chart. Now this Year value is coming from Year Slicer ; so when i clicked 2018 it should display sales for 2018, 2017,2016,2015 and 2014 respectively. and if i choose 2017 then till 2013 .

 Please suggest me some dynamic dax code where i can pass this value and get the resuly.

 

Trend Report.JPG

6 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi Parihar1980

    I'm afraid no direct feature can achieve this, Here is a workaround.

    1. create a calendar table (table2) and manage relationship between two tables.

    2.create measures in Table2, then add "year" column from Table 1 to the slicer.

    Measure = SELECTEDVALUE(Table2[year])
    Measure 2 = [Measure]-MAX('Table'[year])
    Measure 3 = IF([Measure 2]>=0&&[Measure 2]<5,1,0)

     

    3. add [measure3] to Visual Filter.

     

    Finally, it works as your requirement

     

     

    Best Regards

    Maggie

    • Parihar1980's avatar
      Parihar1980
      Icon for Helper II rankHelper II

      many thanks for your feedback. But I am using tabular model and I can't see this funcation while importing my model (SSAS) and using this i am creating my report. 

       Also SELECTEDVALUE funcation working in Direct query OR Import Mode not with tabular model

      Any help or suggestion ?

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Icon for Super User rankSuper User

        Hi,

         

        To keep things simple, why can you not just select 5 years instead of just 1?