+ Reply to Thread
Results 1 to 7 of 7

PowerQuery - Remove null and shift values upwards

  1. #1
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Question PowerQuery - Remove null and shift values upwards

    Hi All

    Below in blue is the existing structure I have (after doing certain transformations). I would like to move the values 'upwards' if the above rows are null values (please refer to the table on the right).

    Photo.png

    I have seen a similar solution on this forum but the number of rows isn't fixed here - one country can have 10 rows, another only 5 rows. There is a similar solution on Stackflow but I am not sure where to input/how to use it on PowerQuery within PBI.

    Many thanks!
    Attached Files Attached Files
    Last edited by swong1709; 08-01-2021 at 12:04 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,857

    Re: PowerQuery - Remove null and shift values upwards

    If the following presentation works for you, then unpivot your data in PQ, close and load to Power Pivot. Build a measure with ConcatenateX to combine the sports. Tried to sort medals to Gold, Silver, Bronze but could not figure that out.

    =CONCATENATEX(Table1,Table1[Value],", ")

    Excel 2016 (Windows) 32 bit
    G
    H
    I
    J
    10
    11
    Sport Attribute
    12
    Country Bronze Gold Silver
    13
    Australia Badminton Swimming
    14
    China Swimming Rifle, Table Tennis Archery, Table Tennis
    15
    USA Basketball, Swimming, 100m Archery
    Sheet: Sheet1
    Last edited by alansidman; 07-31-2021 at 11:42 AM.
    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

  3. #3
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Re: PowerQuery - Remove null and shift values upwards

    Many thanks, Alan for your quick reply. I am afraid I need to have the same format (each sport needs a separate row)

    Below is the link on another website that works but I wasn't sure where to put the code into PowerQuery

    https://stackoverflow.com/questions/...ll-power-query

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: PowerQuery - Remove null and shift values upwards

    Please try

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: PowerQuery - Remove null and shift values upwards

    This is not the same as yours. In the StackOverflow example there is NO category column, so you'd end up with disciplines lined up against the wrong country. There may be a way to adapt it, however I looked at it and wasn't able to work out how to for your scenario.

    EDIT: I was hoping that Bo_Ry would come along!!! Nice one!
    Last edited by AliGW; 07-31-2021 at 12:16 PM.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Smile Re: PowerQuery - Remove null and shift values upwards

    Thanks for looking into this issue.

  7. #7
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Thumbs up Re: PowerQuery - Remove null and shift values upwards

    Quote Originally Posted by Bo_Ry View Post
    Please try

    Please Login or Register  to view this content.
    Many thanks! This is exactly what I need.

+ 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] Shift data upwards if row is cleared
    By DMA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2019, 07:00 AM
  2. [SOLVED] PowerQuery shows null, CSV files dont have (blanks)
    By saudi_red_neck in forum Excel Charting & Pivots
    Replies: 14
    Last Post: 11-12-2019, 09:41 AM
  3. [SOLVED] Summarize table, remove null values, return column headings as rows
    By TFiske in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2018, 12:05 PM
  4. How to remove null values from several columns with Power Query?
    By toblju in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2016, 11:08 AM
  5. Macro needed to shift empty rows upwards while protecting the formula
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 09-21-2015, 01:45 PM
  6. How to remove null values in a data table below a graph
    By Exceluser123456 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-26-2011, 10:55 AM
  7. Adding or pasting a row, but having info shift upwards not down??
    By j. martinez in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-10-2006, 03:25 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