Power Query - Adding a Conditional Index Column

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024

ความคิดเห็น • 16

  • @kebincui
    @kebincui 2 หลายเดือนก่อน

    Amazing 👍. Thanks James and looking forward to more and more videos from you ❤

  • @FsoOmar
    @FsoOmar 10 วันที่ผ่านมา

    WOW! Just mind blowing. Never knew that you could use Records instead of the let statement in that context. I remember you did a video before, where you did crazy transformations inside the nested tables using the let statement.
    Yes Records are better.
    Learned 2 new fns List.Repeat & List.PositionOf. Being the noob I am, I had to watch this amazing video a couple of times to grasp its real beauty.

    • @basensei8699
      @basensei8699  5 ชั่วโมงที่ผ่านมา +1

      aaah man this is awesome!

  • @AnilKumar-vi8oe
    @AnilKumar-vi8oe 3 หลายเดือนก่อน

    You are just amazing man, concepts and solutions you bring are out of the box...

  • @gFowmy
    @gFowmy 4 วันที่ผ่านมา

    The POWR of RECORDS, Amazing! I learnt a new function List.Repeat.
    I mostly watch your to understand the problem and try myself then continue to watch how you tackle it, then learn something new always.
    Here is my solution (my 2 cents):
    let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    threshhold = 120,
    t_group = Table.Group(Source, {"PortfolioCode"},
    {
    {"Tbl", each

    let
    t = _,
    t_index = Table.AddIndexColumn( t , "Index", 0 , 1),
    min_no = List.Min(Table.SelectRows( t_index , each [Cumulative investment Amount] > threshhold )[Index]),
    t_newcol = Table.AddColumn( t_index , "Col", each if [Cumulative investment Amount] > threshhold then [Index] - min_no+1 else 0)

    in
    t_newcol
    }
    }
    ),
    t_removecol = Table.RemoveColumns( t_group , "PortfolioCode" ),
    t_expanded = Table.ExpandTableColumn(t_removecol, "Tbl",List.RemoveItems(Table.ColumnNames( t_removecol[Tbl]{0} ), {"Index"} ) )
    in
    t_expanded

    • @basensei8699
      @basensei8699  5 ชั่วโมงที่ผ่านมา +1

      i love this ! this is a great solution! Nested Let!

  • @williamarthur4801
    @williamarthur4801 3 หลายเดือนก่อน

    That is brilliant, and I'm still working on understanding how it all fits together, but I did have a go myself,
    this did mean having a unique date or index column, then Table.SelectRows(

  • @RonDavidowicz
    @RonDavidowicz 3 หลายเดือนก่อน

    Another great video, would like to hear the real-world situation that prompted this. Seems like a strange thing to need to accomplish.

  • @themolestones
    @themolestones 3 หลายเดือนก่อน

    amazing video

  • @pamphlex
    @pamphlex 3 หลายเดือนก่อน

    So in a record you squeeze 2 integers, 1 list and 1 table... Nice! I want you do it (same outcome) with nested LET, to really make a point.

  • @tonybatty504
    @tonybatty504 3 หลายเดือนก่อน

    Looks interesting but I'm going to have to work through that quite a few times to understand what is happening in each step.

  • @gnsarathbabu
    @gnsarathbabu 3 หลายเดือนก่อน

    Hi Sensai, could you please let me know whether this is possible in pq
    I have two tables in powerquery
    One table -Custreview
    ProductId, customer-comments
    100, it sucks
    102, this is amazing
    Second table -custmoderate
    ProductId, lookupword, replaceword
    100, sucks, not good
    100,it, this
    102,amazing,exemplary
    From Custreview table match Product Id with custmoderate table; if matched; take customer comments field from Custreview and replace lookupword with replaceword. One Product Id can have 100's of word that need to be replaced.
    Please guide me how to do it in powerquery.

  • @haroldmadrigal3671
    @haroldmadrigal3671 3 หลายเดือนก่อน

    How can you create a library of custom functions?

    • @basensei8699
      @basensei8699  2 หลายเดือนก่อน

      it's a good idea. i've seen some dudes create these online and make them available. maybe is hould start doing that also.

  • @larmondoflairallen4705
    @larmondoflairallen4705 2 หลายเดือนก่อน

    I think the first step needs to be, "Make sure your data is sorted by date, in ascending order." If the data isn't presorted, the code won't work as expected.

    • @basensei8699
      @basensei8699  2 หลายเดือนก่อน

      true that! my bad!