Forum Discussion

HZAFAR's avatar
HZAFAR
Regular Visitor
3 years ago
Solved

Power Query Function (SUMIF)

Hi Expert

 

I am working in Power Query on Data ( more than 5 files). And I am using one data file (sample table 1) as a base file having a unique ID and want to bring other information from other files based on a Unique ID (Table 2).

 

Table 1
UIDNames
1Jojn
2Bill
3Andry
4Colin
5Sara

 

Table 2
UIDGross SalaryTAXNet Salary
11001090
250545
160654
317017153
21001090

 

Required Result as below Table

 

Required Result
UIDNamesSum of Gross SalarySum of TAXSum of Net Salary 
1Jojn16016144 
2Bill15015135 
3Andry17017153 
4Colin000 
5Sara000 

 

Challenge:

 

Other files' unique ID is repeated more than one time due to multiple entries of information.

 

Can you please help me bring information from other files we used to do in excel by using the sumif formula?

  • Hi HZAFAR,

     

    You can achieve this with the User Interface.

     

    First go to Table2, select Group By on the ribbon

    Set the UID as Key and add aggregations for all other fields (Important! When you have multiple tables, use the Append queries first so you get 1 large table BEFORE this Group By transformation).

     

    Go to Table1, select Merge queries on the ribbon, select UID columns as key in both tables

    And finally expand the aggregate columns from the nested table

    Done

     

    Ps. If this helps solve your query please mark this post as Solution, thanks!

10 Replies

  • m_dekorte's avatar
    m_dekorte
    Resident Rockstar

    Hi HZAFAR,

     

    You can achieve this with the User Interface.

     

    First go to Table2, select Group By on the ribbon

    Set the UID as Key and add aggregations for all other fields (Important! When you have multiple tables, use the Append queries first so you get 1 large table BEFORE this Group By transformation).

     

    Go to Table1, select Merge queries on the ribbon, select UID columns as key in both tables

    And finally expand the aggregate columns from the nested table

    Done

     

    Ps. If this helps solve your query please mark this post as Solution, thanks!

    • HZAFAR's avatar
      HZAFAR
      Regular Visitor

      Thanks a lot for your quick solution.

      one more query on same table 2, I have other column containing text, how i can bring those text column information in nested table, as by using group by >>aggregate option, operator shows only calcuations option i.e SUM, Avg, etc. 

      But i want to bring text column as well. please share your expert advise.thanks. 

      • m_dekorte's avatar
        m_dekorte
        Resident Rockstar

        Hi HZAFAR,

        Create another aggregate column,  stick with a sum, it doesn't really matter as long as you bring in the needed field. Then inside the formula bar change the expression from List.Sum into Text.Combine

        Now this expression takes an additional parameter a separator, here you can enter "as a text" whatever you want to separate the values.

         

        Hope this is helpful.

        Cheers

  •  

    1. Merge the two tables using the "Merge Queries" feature in Power Query. Select the "UID" column from both tables as the join key.  (Home -->Combine-->Merge Queries)

     2. Expand the Merged Table, select the aggregate option for Sum of Gross Salary, Tax and Net

    3. The aggregate sum values are displayed but "null" is shown. Have to replace it

     

    4. Select entire table, Power Query -->Transform Data-->Replace Values-->Replace "null" with 0.

     

     

     

     

     

    • HZAFAR's avatar
      HZAFAR
      Regular Visitor

      Thanks a lot for your quick solution.

      one more query on same table 2, I have other column containing text, how i can bring those text column information in nested table, as by using group by >>aggregate option, operator shows only calcuations option i.e SUM, Avg, etc. 

      But i want to bring text column as well. please share your expert advise.thanks.