+ Reply to Thread
Results 1 to 9 of 9

Power Query count rows

  1. #1
    Forum Contributor
    Join Date
    07-18-2014
    Location
    Missouri, USA
    MS-Off Ver
    2010
    Posts
    175

    Power Query count rows

    I created an index column after sorting a column descending. Now, I want to create a new custom column taking their index number divided by the number of total rows or Max index number:

    New Column = [Index]/Countrows(Table) or New Column = [Index]/Max([Index])

    Example:
    HTML Code: 

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

    Re: Power Query count rows

    See if this link helps

    https://community.powerbi.com/t5/Des...mn/td-p/218038
    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
    Forum Contributor
    Join Date
    07-18-2014
    Location
    Missouri, USA
    MS-Off Ver
    2010
    Posts
    175

    Re: Power Query count rows

    The link looks like a DAX solution but I'm using Power Query so I need a M language solution. Or can you use DAX formulas in power query?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Power Query count rows

    You can create another query that just returns the max index number, then in yoyur main query add a custom column using a formula like:

    #"Name of max query"{0}

    which will return a record for each row, and you just expand that.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Contributor
    Join Date
    07-18-2014
    Location
    Missouri, USA
    MS-Off Ver
    2010
    Posts
    175

    Re: Power Query count rows

    I have no idea how to do the steps you suggested. I'm surprised that in the M language, you can't just write:

    New Column = [Index] / Table.RowCount(Table) but this doesn't work as I've found out.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Power Query count rows

    Actually, you can do that - you just need to use the name of the previous step as the table name. So if you'd just added an Index column, it would be something like:

    =[Index]/Table.RowCount(#"Added Index")

  7. #7
    Forum Contributor
    Join Date
    07-18-2014
    Location
    Missouri, USA
    MS-Off Ver
    2010
    Posts
    175

    Re: Power Query count rows

    Perfect. This worked. Now, one more. Can I use a similar formula to pull the MAX number from my recently added column?

    Like:
    New Column = [Column] / Max(#"Added Index1")

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Power Query count rows

    I think you'd be back to a separate query for that - although if you're referring to the column you just created, isn't the max value just 1?

  9. #9
    Forum Contributor
    Join Date
    07-18-2014
    Location
    Missouri, USA
    MS-Off Ver
    2010
    Posts
    175

    Re: Power Query count rows

    Actually, I was typing out a response of what I'm doing and realized a way to do what I need without a "Max" function.

    Thanks for your help!

+ 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] Excel Power Query - count formla, same entry shoud listed like A1,A2,A3
    By zeko90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2019, 02:45 PM
  2. Power Query from Folder - BUT not consolidating the top rows
    By Mikael37167 in forum Excel General
    Replies: 6
    Last Post: 12-10-2018, 05:20 PM
  3. [SOLVED] Select Rows between blank rows using Power Query
    By beaglesBuddy in forum Excel General
    Replies: 5
    Last Post: 08-17-2018, 08:30 PM
  4. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  5. Multi rows into Single row using power query
    By alipezu in forum Excel General
    Replies: 4
    Last Post: 10-22-2017, 08:02 AM
  6. Replies: 11
    Last Post: 08-01-2017, 06:08 AM
  7. Remove Unique rows in Power Query
    By danielmorrison in forum Excel General
    Replies: 2
    Last Post: 03-11-2016, 09:06 AM

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