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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Summarize (Pivot) Table

Hi All,

 

I'm an excel user trying to model some data in Power BI, but am stuck on the equivalent of a pivot. If I was in Excel, I would pivot the first table below to remove source code, then do a lookup to another table to bring in the sum of another column for each unique value of "Area Code 2" + "GL Account". What's the best way to do this in Power BI? I've tried SUMMARIZECOLUMNS and CALCULATE TABLE but not sure if I'm even on the right track.

 

If anyone has a good post on how to convert from being an Excel User to a Power BI user that would be super too. 

 

Thanks in advance. 

 

This is my base data.This is my base data.I need to use a combination of Area Code 2 & GL Account to bring in the sum of data from another table.I need to use a combination of Area Code 2 & GL Account to bring in the sum of data from another table.

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Sorry, I haven't described my scenario clearly.

 

The formula I shared in my second reply should be useful when you created the relationship with Link colunm for the two tables.

 

If you don't have relationship, you should use this formula below.

 

Column = CALCULATE (
    SUM ( Table2[FTE Proportion] ),
    FILTER ( 'Table2','Table2'[Link]=EARLIER(Table1[Link] ) )
)

 Just wondering if there are values in 'Table1', but no matching value in 'Table2' if it will return a value of zero, or if it will cause a problem? 

 


 

For your question, I think this expample should explain this scenario. In Table 1, we have different links but in Table 2 we only have one matched link. For the result column, we could see if there is no matched values in table 2, it will show blank in Table1.

 

I also made a simple example which should make you clear.

 

Untitled.png

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

13 REPLIES 13
BobBI
Resolver III
Resolver III

Hi ,

 

Not sure what extactly you were trying to achieve , however you can try this and play around little bit to get the desired output.

 

Your base data is in Table1 ,  Create a calculated table "NewTable" , group by Area code/GL account

Note : you can also create a composite key 'CK' to combine area code 2 and GL to uniquely identify each row.

 

NewTable=

SUMMARIZE(Table1,
        Table1[Area Code 2],
        Table1[GL Account],
        "CK",Table1[Area Code 2]&Table1[GL Account],
        "Total",CALCULATE(sum(Table1[Total amount]))
        
         )

 

now if you have to loop value from another table your LookupValue funciton

"lookupValue", LOOKUPVALUE(Table2[total amount],table2[CK],table1[CK])

 

Hope this gives you a direction.

 

Good luck ,

SS

Anonymous
Not applicable

Hi,

 

Thank you. The DAX for the NewTable worked, but I'm still not getting the right answer with the lookup. I think I need the equivalent of a SUMIF. In my new table I have a single unique value on each row, but the same value is on multiple rows on the second table and I need the sum of each of those rows. Can you help me with the correct order for the CALCULATE function? Not sure if I have explained this well enough. 

 

Table 1:

A

B

C

 

Table 2:

A  1

A  2

A  3

 

The function should return a new column in Table 1 that has a total of 6 next to A. 

PattemManohar
Community Champion
Community Champion

@Anonymous It will be great if you can post some sample data (copiable format) and expec. But anyway based on your post, I can suggest you to create an intermediate calculated table (With sum of values of a field you are interested in with group by Area Code 2 and GL Account) from your main lookup table. Now this intermediate table will be your lookup table which already has summed up values for each combination of AreaCode 2 + GL Account. Hope this helps !!





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

Thank you for the help. 

Hi @Anonymous,

 

What about this measure?

 

Measure =
CALCULATE (
    SUM ( Table2[value] ),
    FILTER ( 'Table2', 'Table2'[Table] = RELATED ( Table1[Table 1] ) )
)

If you still need help, please share your data sample as table format so that I can make a copy and have test with your data sample.

 

In addition, I would appreciate it if you could share your desired output.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Cherry,

 

Thanks for your help. I tried your DAX expression, but it returns the same number for every row. 

 

I can't see how I can attach a file for you to test the data on. I have an excel version that I can attach if that's possible. I've copied and pasted below, maybe that will work. When I use the DAX expression you gave me I get the result in column "FTE". 

 

My tables are related through the colulmn "link". What I'm trying to do is for every row that has a unique value (ie. Link = 201611001), sum up all the values in the "FTE Proportion" column of the second table, and put them in a new column in the first table. Hope that makes sense. In excel a sumif formula would do this for me. 

 

COLL2COLL3FFS Level 3GL AccountLinkTotal AmountAllocation 1Allocation 2FTESUMIF
210002016130111001201611001882501.76661876.32220625.443.1367303094.98
210002016130131701201611701169228.68159632.389596.33.1367303090.65
210002016130141101201611101138464.76131989.626475.143.1367303090.08
21000201793011100120179100113032089.398743944.574288144.823.13673030967.42
21000201793013170120179170118569913.689159696.049410217.643.136730309114.2
2100020179301411012017911012606951.972251952.71354999.263.13673030953.51
210002110030111001211001001221992.36166494.2755498.093.1367303093.03
210002110030131701211001701757491.66757491.6603.1367303090.08
2200020176301110012017610017734973.496282546.3291452427.1613.13673030952.58
2200020176301317012017617014647075.433353017.661294057.773.13673030926.57
2200020176301411012017611012704472.892634420.3570052.543.13673030930.22
2200020180301110012018010015619435.234720325.593899109.63683.13673030946.97
2200020180301317012018017012437414.142251792.75185621.393.1367303097.28
2200020180301411012018011014412830.234399555.813274.433.13673030924.35
22000221003011100122100100147143.9739600.93487543.03523.1367303090
220002210030131701221001701526079.55526079.5503.1367303091.9
220002210030141101221001101229.99229.9903.1367303090
22000223003014110122300110124.8424.8403.1367303090

 

 

 

COLL2COLL3GL Cost CentreGL Project CodeGL Natural AccountFTE ProportionLINK
2100020161594203210010.18201611001
2100020161594203210010.41201611001
2100020161594203210010.15201611001
2100020161594203210010.06201611001
2100020161594203210010.42201611001
2100020161594203210010.16201611001
2100020161594203210010.16201611001
2100020161594203210010.03201611001
2100020161594203210010.03201611001
2100020161594203210010.08201611001
2100020161594203210010.02201611001
2100020161594203210010.04201611001
2100020161594203210010.03201611001
2100020161594203210010.11201611001
2100020161594203210010.09201611001
2100020161594203210010.41201611001
2100020161594203210010.03201611001
2100020161594203210010.07201611001

Hi @Anonymous,

 

Please create the calculated column with this formula below.

 

Column = CALCULATE (
    SUM ( Table2[FTE Proportion] ),
    FILTER ( 'Table1','Table1'[Link]=EARLIER(Table1[Link] ) )
)

Then you could get the output like below.

 

Untitled.png

 

The 2.48 is the sum of FTE Proportion which the link is 20161101 in the sceond table.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Again,

 

Just wondering if there are values in 'Table1', but no matching value in 'Table2' if it will return a value of zero, or if it will cause a problem? 

 

Regards,

Verity

Hi @Anonymous,

 

Sorry, I haven't described my scenario clearly.

 

The formula I shared in my second reply should be useful when you created the relationship with Link colunm for the two tables.

 

If you don't have relationship, you should use this formula below.

 

Column = CALCULATE (
    SUM ( Table2[FTE Proportion] ),
    FILTER ( 'Table2','Table2'[Link]=EARLIER(Table1[Link] ) )
)

 Just wondering if there are values in 'Table1', but no matching value in 'Table2' if it will return a value of zero, or if it will cause a problem? 

 


 

For your question, I think this expample should explain this scenario. In Table 1, we have different links but in Table 2 we only have one matched link. For the result column, we could see if there is no matched values in table 2, it will show blank in Table1.

 

I also made a simple example which should make you clear.

 

Untitled.png

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you. I found my problem, my data in my link column wasn't correct for one of the tables. 

 

The formula works perfectly. 

Hi @Anonymous,

 

You're welcome. It's glad that we can help.Smiley Very Happy

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks Cherry,

 

Makes perfect sense but I must have something wrong as I'm still not getting a result. Can you share your dummy file with me so I can try to work through where I've missed something? 

Anonymous
Not applicable

Hi Cherry,

 

Thanks again for your help. 


Can you please explain what the filter is doing? Why does it only refer to Table1? 

 

I've tried using the formula as written, and also substituting Table2 into the formula but I keep returning blank rows. 

 

Regards,

Verity

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.