Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Shift value in a column by Dax function

Hi all,

 

I would like to know Is there any function in Dax help shift values in a column.

For example:

Column 1Column 2Column 3
1aa
2bb
3cc
4dd
5ee
6ff
7gg
8hh
9ii

 

Desired result after shifted down 4 rows:

 

Column 1Column 2Column 3
1aa
2bb
3cc
4dd
5ae
6bf
7cg
8dh
9ei

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    Try this

    create one column

    if(table[Column1]<=4,Column2,Lookupvalue(table[Column2],table[Column1],table[Column1]-4)

     

    Thanks & regards,
    Pravin Wattamwar
    www.linkedin.com/in/pravin-p-wattamwar

    If I resolve your problem Mark it as a solution and give kudos.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello Anonymous ,

       

      Can we express it as a Measure like DATEADD or PARALLELPRERIOD?

      In detail, I want to calculate a total Count with Previous Date Period but My data drilled down by Hour. When I use DATEADD or PARALLELPRERIOD, in thrown an exception because column date has duplicated value.

       

      My date by count like 

      TimeCount
      01/01/2018 10:00:00 PM4
      01/01/2018 11:00:00 PM2
      02/01/2018 12:00:00 AM2
      02/01/2018 01:00:00 AM6
      02/01/2018 02:00:00 AM4
      02/01/2018 03:00:00 AM9
      02/01/2018 04:00:00 AM0
      • amitchandak's avatar
        amitchandak
        Super User

        Can You explain with the exact source and output?  not making it clear using two posts. Mark me @

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi amitchandak  and Anonymous ,

     

    Sorry for make you confused.

    I current have data of count drilled down by hour.

    I know in DAX have a function to calculate same previous date or month (DATEADD or PARALELLPERIOD)

    But this two functions cannot use within a column have duplicated values, and my column date has data/time date so it has duplicate date values.

    TimeCount
    01/01/2018 10:00:00 PM4
    01/01/2018 11:00:00 PM2
    02/01/2018 12:00:00 AM2
    02/01/2018 01:00:00 AM6
    02/01/2018 02:00:00 AM4
    02/01/2018 03:00:00 AM9
    02/01/2018 04:00:00 AM0

     

    How can I calculate previous period with this table?

    • amitchandak's avatar
      amitchandak
      Super User

      We typically create a date column on timestamp column and use that in time intelligence with date table

      Date = Table[timestamp].date

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hello amitchandak ,

         

        I am struggling with this case.

        I current ly have a table like this.

        TimeCountExpected (if shift 3 rows)
        01/01/2018 10:00:00 PM4 
        01/01/2018 11:00:00 PM2 
        02/01/2018 12:00:00 AM2 
        02/01/2018 01:00:00 AM64
        02/01/2018 02:00:00 AM42
        02/01/2018 03:00:00 AM92
        02/01/2018 04:00:00 AM06

        How can I use DATEADD function with this table?

        In my topic, you mentioned use 

        Date = Table[timestamp].date

        Could you please help me explain more how to use this?

        I want to calculate a count shifted by specific days, just like DATEADD function.

         

        Thank you for your help.