Thursday, December 10, 2020

Power Query - SubQuery LastTime by Category

    //Sub Query LastTime by Category 

    Grouped = Table.Group(#"Removed Columns", {"Acao"}, {{"AllData", each _, type table}, {"MaxUpdated", each List.Max([Updated]), type datetime}}),

    SelectedMax = Table.AddColumn(Grouped, "Custom", (x) => Table.SelectRows(x[AllData], each [Updated] = x[Updated] & [Acao] = x[Acao])),

    RemovedColumns = Table.RemoveColumns(SelectedMax,{"Custom", "Acao"}),

    #"Expanded AllData1" = Table.ExpandTableColumn(RemovedColumns, "AllData", {"Date", "Open", "High", "Low", "Close", "Volume", "Acao", "Updated", "volume_adi", "volume_obv", "volume_cmf", "volume_fi", "volume_mfi", "volume_em", "volume_sma_em", "volume_vpt", "momentum_kama", "momentum_roc", "momentum_ppo", "momentum_ppo_signal", "momentum_ppo_hist", "others_dr", "others_dlr", "File", ".Index", ".PK_Acao_Date"}),

    #"Added Custom3" = Table.AddColumn(#"Expanded AllData1", "Val", each if [MaxUpdated] = [Updated] then 1 else 0),

    TableUpdate = Table.SelectRows(#"Added Custom3", each ([Val] = 1)),

No comments:

Post a Comment

Power BI APP - Delete or Unpublish

 UNPUBLISH DELETE