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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Mainer04401
Helper III
Helper III

Create new "all other" row by calculating values of other rows

The application I use to pull data is not allowing me to pull all products sales because it's above the maximum amount of data allowed to be pulled.  Instead, I can pull select product sales and an aggregate sales of all products.  Is there a way in Power BI for me to create a new row in the products column or create a new column that subtracts the sales of the select products from the aggregate sales so that I can have an "all other products" row? 

 

Maybe something like IF [Product] not equal to "Aggregate" then show the rows and values as is, but if [Product] = "Aggregate" then subtract the products sum from the aggregate sum.  

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Well you were on the right track already! 🙂 

Measure = 
IF(HASONEVALUE(Table1[Product),
   IF(SELECTEDVALUE(Table1[Product]) = "Aggregrate", 
        CALCULATE(SUM(Table1[Sales], FILTER(ALL(Table1), Table1[Product] = "Aggregrate"))-
       CALCULATE(SUM(Table1[Sales], FILTER(ALL(Table1), Table1[Product] <> "Aggregrate")),
        CALCULATE(SUM(Table1[Sales], FILTER(ALL(Table1), Table1[Product] = SELECTEDVALUE(Table1[Product]))))

Something like this might work (note: untested and written without intellisense). It basically checks if, in the current filtered context, Product has only 1 value and if that value is Aggregate, it sums everything with 'agregrate' and subtracts everything else (not Aggregrate). Otherwise, sum sales of the current selected value of Product.

Let me know if this works for you 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
JarroVGIT
Resident Rockstar
Resident Rockstar

Well you were on the right track already! 🙂 

Measure = 
IF(HASONEVALUE(Table1[Product),
   IF(SELECTEDVALUE(Table1[Product]) = "Aggregrate", 
        CALCULATE(SUM(Table1[Sales], FILTER(ALL(Table1), Table1[Product] = "Aggregrate"))-
       CALCULATE(SUM(Table1[Sales], FILTER(ALL(Table1), Table1[Product] <> "Aggregrate")),
        CALCULATE(SUM(Table1[Sales], FILTER(ALL(Table1), Table1[Product] = SELECTEDVALUE(Table1[Product]))))

Something like this might work (note: untested and written without intellisense). It basically checks if, in the current filtered context, Product has only 1 value and if that value is Aggregate, it sums everything with 'agregrate' and subtracts everything else (not Aggregrate). Otherwise, sum sales of the current selected value of Product.

Let me know if this works for you 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





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

Proud to be a Super User!




Worked brilliantly, thank you!  I changed the formula a bit because the TOTALS weren't populating.  I remove the HASONEVALUE string and everything still appears to work as need.  

 

   IF(SELECTEDVALUE(Table1[Product]) = "Aggregate",
        CALCULATE(SUM(Table1[Sales]), FILTER(ALL(Table1), Table1[Product] = "Aggregate"))-
       CALCULATE(SUM(Table1[Sales]), FILTER(ALL(Table1), Table1[Product] <> "Aggregate")),
        CALCULATE(SUM(Table1[Sales])))

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.