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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to do Excel Sumif in PowerBI?

Hello,

Suppose I have the following (made up) data below:

 
1BCDEFGHI
2StockAmount InvestedLow Projected ValueLow RankMid Projected ValueMid RankHigh Projected ValueHigh Rank
3Amazon$34,376.00$103,128.00Better$154,692.00Good$206,256.00Better
4Tesla$85,544.00$256,632.00Best$384,948.00Best$513,264.00Best
5Microsoft$45,333.00$226,665.00Best$339,997.50Best$453,330.00Best
6Google$40,473.00$121,419.00Better$182,128.50Good$242,838.00Better
7Amazon$91,208.00$91,208.00Better$136,812.00Better$182,416.00Better
8Netflix$9,027.00$9,027.00Bad$13,540.50Bad$18,054.00Bad
9Spotify$35,476.00$70,952.00Good$106,428.00Better$141,904.00Good
10Uber$24,444.00$24,444.00Bad$36,666.00Bad$48,888.00Bad
 

 

My goal is to create this table, where it aggregates the low, mid, and high values based on the rank.

 Low Projected ValueMid Projected ValueHigh Projected Value
Bad$33,471.00$50,206.50$66,942.00
Good$70,952.00$336,820.50$141,904.00
Better$315,755.00$243,240.00$631,510.00
Best$483,297.00$724,945.50$966,594.00

 

in Excel, it's easy. I would just do this:

 

 BCDE
  Low Projected ValueMid Projected ValueHigh Projected Value
15Bad=SUMIF($E$3:$E$10,B15,$D$3:$D$10)=SUMIF($G$3:$G$10,B15,$F$3:$F$10)=SUMIF($I$3:$I$10,B15,$H$3:$H$10)
16Good=SUMIF($E$3:$E$10,B16,$D$3:$D$10)=SUMIF($G$3:$G$10,B16,$F$3:$F$10)=SUMIF($I$3:$I$10,B16,$H$3:$H$10)
17Better=SUMIF($E$3:$E$10,B17,$D$3:$D$10)=SUMIF($G$3:$G$10,B17,$F$3:$F$10)=SUMIF($I$3:$I$10,B17,$H$3:$H$10)
18Best=SUMIF($E$3:$E$10,B18,$D$3:$D$10)=SUMIF($G$3:$G$10,B18,$F$3:$F$10)=SUMIF($I$3:$I$10,B18,$H$3:$H$10)

 

 

So the sumif for the low, mid, and high values are going off of the low, mid, and high ranks, respectively. The output table is not just off of one column, but will need to be three columns. However, I am struggling to get all these calculations in one table in PowerBI. I've tried putting this in the matrix visual, but this only lets me pivot off of one column. I've tried writing some measures in DAX, but I couldn't get that either. 

 

Thanks!

 

Edit:

Clarity in the output table

 

1 ACCEPTED SOLUTION

@Anonymous here is a solution with separate queries (easy to chew), check Power Queries, and the new table is called Goodbad Separate

 

Cheers!!

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
MFelix
Super User
Super User

Hi @Anonymous,

In this case the best option is to unpivot all columns for project amount and rank
Then create a matrix visualization with

rank on rows
Project type on columns
Project value on values.

Should give you expected amounts

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



parry2k
Super User
Super User

@Anonymous I haven't used SUMIF but what is B15,B16,B17,B18 values which are used in SUMIF formula you provided.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi @parry2k , yes, I apologize, it is unclear. The output table I made for B15 to B18 is supposed to refer to the values Bad to Best at the left of the table. The sumif formula is referencing those words as the criteria in the criteria range of the sumif formula. 

 

 BCDE
  Low Projected ValueMid Projected ValueHigh Projected Value
15Bad=SUMIF($E$3:$E$10,B15,$D$3:$D$10)=SUMIF($G$3:$G$10,B15,$F$3:$F$10)=SUMIF($I$3:$I$10,B15,$H$3:$H$10)
16Good=SUMIF($E$3:$E$10,B16,$D$3:$D$10)=SUMIF($G$3:$G$10,B16,$F$3:$F$10)=SUMIF($I$3:$I$10,B16,$H$3:$H$10)
17Better=SUMIF($E$3:$E$10,B17,$D$3:$D$10)=SUMIF($G$3:$G$10,B17,$F$3:$F$10)=SUMIF($I$3:$I$10,B17,$H$3:$H$10)
18Best=SUMIF($E$3:$E$10,B18,$D$3:$D$10)=SUMIF($G$3:$G$10,B18,$F$3:$F$10)=SUMIF($I$3:$I$10,B18,$H$3:$H$10)

@Anonymous see attached, look at table GoodBad and Rank, and all the efforts are in data prep, following the best practice with scalable solution.

 

Ignore other tables in the file, those for not in use.

 

I would 💖 Kudos 🙂 if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thank you very much @parry2k  and @MFelix 

 

Parry, I downloaded your file and looked at the Power Query, and it is very clean. It definitely answers my question, and I will study it and try to implement it. 

One thing is that my actual file has like 50 columns of data, and in my final output table, I will have to add additional columns that may not be compatible with the new transformed format.

Do you think there is a DAX formula that is similar to how the sumif formula works in Excel? The DAX formula would reference the Rows value  in the table visual (bad, good, better, best) to be the criteria parameter, then I could select any field/column in my data table as the criteria range parameter, and then select any field/column in my data table as the sum range parameter. 

 

I know you can do something like:

CALCULATE( SUM(Table[Sum field]), Table[Criteria field]) = "Best")         which is sort of similar.  Could I adjust this formula to dynmically reference the current row name in the matrix/table visual? 

 

Thanks again!

@MFelix direct unpivot will not work because rank is different for each high/low/mid-value, with unpivot, it will require different measures for each type of value but appending the tables (a solution I provided), everything is straight forward from there.

 

I just appended the table in one power query but it will be easier to do it as different queries, easy to manage.

 

here is the output

 

image.png



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Anonymous here is a solution with separate queries (easy to chew), check Power Queries, and the new table is called Goodbad Separate

 

Cheers!!

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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