Forum Discussion

JustDavid's avatar
JustDavid
Helper IV
2 years ago

Transform List - Taking from different fields and taking from List Previous Record (after Transform)

Hello PQ Gurus,

 

Given A List Below

ListDesired Result in List Form

1

10 <- Assume this is the [WeekNum] value of the same record

010
010
112 <- Assume this is the [WeekNum] value of the same record
012
012
012
128 <- Assume this is the [WeekNum] value of the same record
028

 

My question is, how can I tranform this List into when it's a value 1, get it from a different field (i.e. [WeekNum]) and if it's 0, get from the previous List Record?

 

Note that in actuality, I have only 1 column for my List. The "table" above is just to show my desired result from the original list (left side of table 1st column) to my desired end result as a list (right side of table 2nd column)

3 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    NewStep=Table.FillDwon(Table.ReplaceValue(YourTable,each [WeekNum],"",(x,y,z)=>if x=1 then y else null,{"ListCol"}),{"ListCol"})

    • JustDavid's avatar
      JustDavid
      Helper IV

      Gives an error that says 'We cannot convert the value 1 to type Text.

       

      = Table.FillDown(
          Table.ReplaceValue(#"Added Index",each [#"Week Num"],"",(x,y,z)=>if x=1 then y else null,_MyListStepBelowAddedIndex),_MyListStepBelowAddedIndex)
      • wdx223_Daniel's avatar
        wdx223_Daniel
        Community Champion

        = Table.FillDown( Table.ReplaceValue(#"Added Index",each [#"Week Num"],"",(x,y,z)=>if x="1" then y else null,_MyListStepBelowAddedIndex),_MyListStepBelowAddedIndex)