+ Reply to Thread
Results 1 to 8 of 8

Power query grouping - conditional to data across several columns??...

  1. #1
    Registered User
    Join Date
    03-27-2021
    Location
    Belgium
    MS-Off Ver
    365
    Posts
    4

    Question Power query grouping - conditional to data across several columns??...

    Hi
    I am rather new to power queries, and so far building my power pivot was going very well. Until I bumped into this -

    I have a list of orders with corresponding shipment data (3 columns). Shipment data is received from an external source. Every update will create a new line for the same order number.

    for example:

    Order.ItemID ETS ETA Vessel name
    8753060.11 4/21/2021 5/4/2021 MAERSK BULAN
    8753060.11 5/14/2021 6/6/2021 TBN

    Challenge is - I need only one line per order, with the latest update which in this case will be ETS ETA and Vessel name from the last row, i.e. latest ETS and ETA dates.
    I'm struggling to figure out how to achieve that.

    Would appreciate some help!
    Thanks
    sunnyspirit
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by sunnyspirit; 03-28-2021 at 07:30 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,925

    Re: Power query grouping - conditional to data across several columns??...

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.

  3. #3
    Registered User
    Join Date
    03-27-2021
    Location
    Belgium
    MS-Off Ver
    365
    Posts
    4

    Re: Power query grouping - conditional to data across several columns??...

    thanks JohnTopley just uploaded it

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,209

    Re: Power query grouping - conditional to data across several columns??...

    The attached workbook is empty. It may have external links. Please provide the source data live in the workbook and attach again. Thanks.

    Please update your forum profile - your version is 365, not 2008 (which is just a release number). Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    03-27-2021
    Location
    Belgium
    MS-Off Ver
    365
    Posts
    4

    Re: Power query grouping - conditional to data across several columns??...

    done, thanks Ali

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,755

    Re: Power query grouping - conditional to data across several columns??...

    You have multiple columns of ETA and ETS. Which ones should we be analyzing?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  7. #7
    Registered User
    Join Date
    03-27-2021
    Location
    Belgium
    MS-Off Ver
    365
    Posts
    4

    Re: Power query grouping - conditional to data across several columns??...

    yeah, so that's exactly the tricky part..
    there are sometimes multiple rows per order, but I only need one row per order, the one that is containing the latest date in the ETS column, with its respective ETA and Vessel name.
    in other words, instead of having these two rows per order 8753060

    Order.ItemID ETS ETA Vessel name
    8753060.11 4/21/2021 5/4/2021 MAERSK BULAN
    8753060.11 5/14/2021 6/6/2021 TBN

    there will only be this one>

    Order.ItemID ETS ETA Vessel name
    8753060.11 5/14/2021 6/6/2021 TBN

    because ETS 5/14/2021 is later than ETS 4/21/2021, i.e. most up to date data.

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Power query grouping - conditional to data across several columns??...

    If I understand correctly, then I believe this could be accomplished using relatively simple formulas.
    The formulas are applied to columns which have been added to the data table on Sheet1.
    The Filter1 column is populated using: =MAXIFS([ETS],[Order.ItemID],[@[Order.ItemID]])=[@ETS]
    The Filter2 column is populated using: =AND([@Filter1]=TRUE,COUNTIFS(AD$2:AD2,[@[Order.ItemID]],AM$2:AM2,TRUE)=1)
    On Sheet2 the output is displayed using: =IFERROR(INDEX(Table1[Order.ItemID],AGGREGATE(15,6,(ROW(Table1[Order.ItemID])-ROW(Table1[[#Headers],[Order.ItemID]]))/(Table1[[Filter2]:[Filter2]]=TRUE),ROWS($A$1:$A1))),"")
    Note that the data table on Sheet1 could be filtered based on the TRUE's in the Filter2 column to display the results shown on Sheet2.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Power Query/Power Pivot Conditional Column creation & chart
    By mz_h in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-12-2020, 06:07 PM
  2. Data grouping in Power Query
    By hudson andrew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2020, 10:44 AM
  3. Replies: 10
    Last Post: 06-25-2020, 12:19 AM
  4. [SOLVED] Power query missed columns when import data
    By afgi in forum Excel Charting & Pivots
    Replies: 15
    Last Post: 03-24-2020, 09:15 AM
  5. [SOLVED] Get and Transform (Power Query) - Grouping numbers into bands/buckets
    By TheNewUnion in forum Excel General
    Replies: 2
    Last Post: 03-12-2019, 05:37 AM
  6. Replies: 0
    Last Post: 10-25-2016, 02:59 AM
  7. Help with grouping in power query
    By stephme55 in forum Excel General
    Replies: 1
    Last Post: 07-26-2016, 03:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1