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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
tzambo
Frequent Visitor

Duplicate and Display Summary Data From Excel to PowerBI Table

Hello! 

I'm attempting to recreate a summary table from Excel into Power BI.  It's basically performing several SUMIFS statements across different tables and returning the results for review.  The calculations are run for several different conditions (IE: only sum items that are blue in column 1, red in column 2, green in column 3).  Example table below:

 

 Condition 1 (red)Condition 2 (blue)Condition 3 (green)
R1 SUMIFS from table 1   
R2 SUMIFS from table 2   
R3 R1/5   
R4 R1/R2   

 

I've figured out the DAX equivilent of the SUMIFS, and created measures to get a single value per cell, but I can't find a way to insert them into a table manually. 

I've also dug into calculated tables, but due to the table doing different calculations every row, I haven't made much headway in that direction either.  (On that note, is there a way to dynamically add columns based on how many conditions are found?)

Any help is appreciated, thanks!

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @tzambo 

 

You can use union and row functions to create a new table.

Like this:

Table = 
var Red1=CALCULATE(SUM('Table 1'[Value]),'Table 1'[Condition]="Red")
var Blue1=CALCULATE(SUM('Table 1'[Value]),'Table 1'[Condition]="Blue")
var Green1=CALCULATE(SUM('Table 1'[Value]),'Table 1'[Condition]="Green")
var Red2=CALCULATE(SUM('Table 2'[Value]),'Table 2'[Condition]="Red")
var Blue2=CALCULATE(SUM('Table 2'[Value]),'Table 2'[Condition]="Blue")
var Green2=CALCULATE(SUM('Table 2'[Value]),'Table 2'[Condition]="Green")
return
union(
    ROW("Calculation","Sumifs Table 1","Red",Red1,"Green",Green1,"Blue",Blue1),
    ROW("Calculation","Sumifs Table 2","Red",Red2,"Green",Green2,"Blue",Blue2),
    ROW("Calculation","Table/5","Red",Red1/5,"Green2",Green1/5,"Blue",Blue1/5),
    ROW("Calculation","Table/Table 2","Red",Red1/Red2,"Green2",Green1/Green2,"Blue",Blue1/Blue2)
)

vjaneygmsft_0-1645080889459.png

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

 

Best Regards,

Community Support Team _Janey

View solution in original post

6 REPLIES 6
v-janeyg-msft
Community Support
Community Support

Hi, @tzambo 

 

You can use union and row functions to create a new table.

Like this:

Table = 
var Red1=CALCULATE(SUM('Table 1'[Value]),'Table 1'[Condition]="Red")
var Blue1=CALCULATE(SUM('Table 1'[Value]),'Table 1'[Condition]="Blue")
var Green1=CALCULATE(SUM('Table 1'[Value]),'Table 1'[Condition]="Green")
var Red2=CALCULATE(SUM('Table 2'[Value]),'Table 2'[Condition]="Red")
var Blue2=CALCULATE(SUM('Table 2'[Value]),'Table 2'[Condition]="Blue")
var Green2=CALCULATE(SUM('Table 2'[Value]),'Table 2'[Condition]="Green")
return
union(
    ROW("Calculation","Sumifs Table 1","Red",Red1,"Green",Green1,"Blue",Blue1),
    ROW("Calculation","Sumifs Table 2","Red",Red2,"Green",Green2,"Blue",Blue2),
    ROW("Calculation","Table/5","Red",Red1/5,"Green2",Green1/5,"Blue",Blue1/5),
    ROW("Calculation","Table/Table 2","Red",Red1/Red2,"Green2",Green1/Green2,"Blue",Blue1/Blue2)
)

vjaneygmsft_0-1645080889459.png

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

 

Best Regards,

Community Support Team _Janey

Hello @v-janeyg-msft!

You're a life saver, thank you so much! 

One quick question before I mark accepted - While this serves my purposes now, what if in the future the number of color columns changes?  Is there a way dynamically pull the columns (IE: what if someone adds a purple color to the color columns). 

Hi, @tzambo 

 

In my formula, you can clearly see that this is a static way of constructing a table of rows and columns. So when a new color exists, you need to manually add a line of code row(...) in the union.

 

If you first add table columns to table1 and table2, then append the two tables, and then use the transpose function to change the condition from a column to a row, it may be dynamic, but need to rewrite several measures to meet your needs, and the results may not be the same as what you need now.

 

Janey

Thank you!  I was able to get it working both ways you suggested. 

tzambo
Frequent Visitor

Sure thing!  Here's an example:

Raw data:

Table 1

ValueCondition
1red
1red
2green
2green
3blue
3blue

 

Table 2

ValueCondition
4red
4red
5green
5green
6blue
6blue

 

Results to Replicate

CalculationRedGreenBlue
Sumifs Table 1246
Sumifs Table 281012
Table 1 / 5.4.81.2
Table 1 / Table 2.25.4.5

 

 

amitchandak
Super User
Super User

@tzambo ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors