Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
HZAFAR
Regular Visitor

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?

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

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).

m_dekorte_0-1681990709449.png

 

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

m_dekorte_1-1681990926761.png

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!

View solution in original post

10 REPLIES 10
Syndicate_Admin
Administrator
Administrator

 

  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.

 

 

 

 

 

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. 

I would like to add to this proposed method the following article:

thebiccountant.com | Performance tip for aggregations after joins 

m_dekorte
Super User
Super User

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).

m_dekorte_0-1681990709449.png

 

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

m_dekorte_1-1681990926761.png

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!

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. 

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

HI Dear,

I tried but could not succedded, please see below query with data example and suggest with screenshot for better understanding.

 

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

 

Table 2
UIDGross SalaryTAXNet SalaryDepartment
11001090Finance
250545HR
160654Finance
317017153Sales
21001090HR

 

 

Required Result
UIDNamesSum of Gross SalarySum of TAXSum of Net SalaryDepartment
1Jojn16016144Finance
2Bill15015135HR
3Andry17017153Sales
4Colin000 
5Sara000 

 

Hi @HZAFAR,

 

Here the grouping steps in images, if Department is unique for each UID you could add it to the grouping (A) - otherwise this approach will retrieve all unique Departments (B).

m_dekorte_1-1682235373592.png

 

Initially that will return an error, as shown here

m_dekorte_2-1682235487231.png

 

 Small adjustment to the code will fix that

m_dekorte_3-1682235571006.png

{ “Department”, each Text.Combine( List.Distinct( [Department] ), “, “ ), type nullable text }

 

Now the aggregated Table2 can be merged with the UID from Table1

m_dekorte_4-1682235654386.png

 

Expand the fields of interest from the nested table

m_dekorte_5-1682235726064.png

 

With this result

m_dekorte_6-1682235760976.png

 

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

 

HI ,

 

I am unable to read the samll adjustment in formula change as the text is too tinly. Would you please write the what has to be adjusted/chmages in formula. 

Hi @HZAFAR,

I've added the code above and will leave it here for you as well

{ “Department”, each Text.Combine( List.Distinct( [Department] ), “, “ ), type nullable text }

 

BTW you can click on an image to enlarge it.

 

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

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors