Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
4 years ago

Switching between dates and columns

Hello community!

I need your help because I have a problem that is not solved, I have tried nesting IF functions but I do not get a result, I show you below an example of the table that I have to count with 12k records and is updated daily.

JepGr_0-1644920878289.png

I would need a measurement that would tell me if the value changes between columns and days and how much value moves between columns, knowing that every month I have one more column and that every day rows are added.

Thanks in advance

7 Replies

    • Syndicate_Admin's avatar
      Syndicate_Admin
      Administrator

      Of course you do, thank you very much

      Exit:

      Sales documentMoved to 22/02Moved to 22/03Moved to 22/04Moved to 22/05Moved to 22/06Moved to 22/07Moved to 22/08Moved to 22/09Moved to 22/10Moved to 22/11Moved to 22/12
      778859600144150000000

      0

      Entrance:

      Sales documentOpen 22/01Open 22/02Open 22/03Open 22/04Open 22/05Open 22/06Open 22/07Open 22/08Open 22/09Open 22/10Open 22/11Open 22/12Data Snapshot
      7788596 14415,5 31/01/2022
      7788596 14415,5 01/02/2022
      7788596 14415,5 02/02/2022
      7788596 14415,5 03/02/2022
      7788596 14415,5 04/02/2022
      7788596 14415,5 07/02/2022
      7788596 14415,5 08/02/2022
      7788596 14415,5 10/02/2022
      7788596 14415,5 11/02/2022
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi JepGr ,

         

        It is suggested to unpivot the columns to one date column.

        You can select the Sales document column and select Unpivot Other Columns.

        Then you can convert the Attribute column to the YearMonth column.

         

         

         

        Hope it helps.

         

         

        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.

         

  • Hello, back to the matter:

    In the end using the method of "Unpivot columns" I achieved this:

    JepGr_0-1646050581295.png

    Do you think it is possible to get a measure that indicates whether there has been a change in the "attributte" column and that returns the value of the "value" column only once? Considering that the original table has thousands of rows...

    Thank you

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi JepGr ,

       

      Add a index column in Power QuerySort in the following order in Power Query, and then add an index column.

       

      Then you can create a measure to show the change of 'Attribute' and return the value of the 'value'.

      Measure = IF(MAX('Table'[Attribute])<>CALCULATE(MAX('Table'[Attribute]),FILTER(ALL('Table'),[Index]=MAX('Table'[Index])-1)),SUM('Table'[Value]))

       

       

      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.

      • Syndicate_Admin's avatar
        Syndicate_Admin
        Administrator

        Hi Sthepen!

        That works!!! Thank you very much! I'm trying to add more filters to the measure (without success) in order to only run when the Sales order is the same, so in this situation the measure is not working because this is a different sales order:

        JepGr_0-1646220666808.png

        I try with the earlier fx inside the Calculate:

        JepGr_1-1646221051792.png

        What I'm doing wrong?