+ Reply to Thread
Results 1 to 6 of 6

Filter and sum data according to conditions power query

  1. #1
    Forum Contributor
    Join Date
    07-08-2014
    Location
    israel
    MS-Off Ver
    office 365
    Posts
    101

    Filter and sum data according to conditions power query

    Hey

    I group the data in my data table according to the first 4 columns and I got the sum for the columns "No_P" and "NoSold_P".

    Regarding the additional column "Amount_Spent", I want to sum it in two different ways, so I added a new column "Amnt", then selected all the rows and got the data in the table

    I want to sum the data of "Amount_Spent" once in a new column according to all the rows in the table
    and a second to sum the data only on the condition that the "No_P" field in the table is not empty or greater than zero.

    Additionally I would like to count how many occurrences for each table in "Amnt" has a null or zero value

    Would appreciate help
    I tried for several hours to solve it myself without success...
    Attached Files Attached Files

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Filter and sum data according to conditions power query

    For the total, add a new column using:
    =List.Sum([Amnt][Amount_Spent])

    For the restricted total, something like:
    =List.Sum(Table.SelectRows([Amnt], each [No_P]>0)[Amount_Spent])

    and for the count:
    =Table.RowCount(Table.SelectRows([Amnt],each [No_P] = 0 or [No_P] = null))
    Rory

  3. #3
    Forum Contributor
    Join Date
    07-08-2014
    Location
    israel
    MS-Off Ver
    office 365
    Posts
    101
    Quote Originally Posted by rorya View Post
    For the total, add a new column using:
    =List.Sum([Amnt][Amount_Spent])

    For the restricted total, something like:
    =List.Sum(Table.SelectRows([Amnt], each [No_P]>0)[Amount_Spent])

    and for the count:
    =Table.RowCount(Table.SelectRows([Amnt],each [No_P] = 0 or [No_P] = null))
    Thank you

    How can i do the same using Filter?

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Filter and sum data according to conditions power query

    I don't understand what you mean. Table.SelectRows is the M code for the filtering you do in the PQ editor.

  5. #5
    Forum Contributor
    Join Date
    07-08-2014
    Location
    israel
    MS-Off Ver
    office 365
    Posts
    101
    Quote Originally Posted by rorya View Post
    I don't understand what you mean. Table.SelectRows is the M code for the filtering you do in the PQ editor.
    Can i use DAx function in power qweary?

    Somthung like

    Filter 1st example = FILTER(
    DimProduct,
    DimProduct[Color]='Red')

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Filter and sum data according to conditions power query

    No, you can't use DAX in Power Query. That is for Power Pivot or Power BI.

+ 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. Power Query Filtering with Conditions
    By andrewc in forum Excel General
    Replies: 0
    Last Post: 09-28-2023, 02:44 PM
  2. Replies: 2
    Last Post: 08-03-2023, 09:18 AM
  3. [SOLVED] [Power Query] How to filter 0 from two columns in power query editor in one step?
    By daliye in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2023, 09:44 PM
  4. Remove duplicate rows in Power Query based on various conditions
    By Mayasak in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-27-2022, 08:42 PM
  5. Power query filter
    By Undo in forum Excel General
    Replies: 1
    Last Post: 11-18-2021, 02:08 PM
  6. [SOLVED] Power Query Filter
    By Richard_BAC in forum Excel General
    Replies: 25
    Last Post: 08-11-2020, 01:55 PM
  7. [SOLVED] Power Query code to test for multiple conditions
    By kersplash in forum Excel Formulas & Functions
    Replies: 30
    Last Post: 07-18-2018, 04:51 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