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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
duane1
Frequent Visitor

Sum values in Column C where the value in Column B matches value in Column A

Hi.

In my table below, I would like to sum the values in "FROM_COUNT2" where the value in "FROM_PRODUCTID" matches the vaue in "TO_PRODUCTID".  In this example, the TO_COUNT2 column should contain the sum of all the FROM_COUNT2 values where the TO_PRODUCTID matches the FROM_PRODUCTID.  In excel, I would use SUMIF to do this easily.  Sometimes, there is more than one value in the TO_PRODUCTID that matches the FROM_PRODUCTID.

Screenshot 2024-12-18 110949.png

 

This is in Power Pivot but I assume the same formula I would use in other power platforms like BI or query.  Let me know if it should be posted elsewhere.  Thanks.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @duane1 ,

Would you like to achieve the following results?

1.png

Please try to add a new column and use the code below.

 

TO_COUNT2 = 
CALCULATE(
    SUM(TEST[FROM_COUNT2]),
    FILTER(
        TEST,
        TEST[TO_PRODUCTID] = EARLIER(TEST[FROM_PRODUCTID])
    )
)

 

Could you please provide example data or sample files here if you have any confused? We could offer you more help if we have information in detail. There is sensitive data that can be removed in advance. How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Thanks for your understanding. Your time and cooperation are much valued by us. We are looking forward to hearing from you to assist further.

Best regards,

Lucy Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

Bibiano_Geraldo
Super User
Super User

Hi @duane1 ,

Create a new calculated column using this DAX:

TO_COUNT2 = 
CALCULATE(
    SUM(TableName[FROM_COUNT2]),
    FILTER(
        TableName,
        TableName[TO_PRODUCTID] = EARLIER(TableName[FROM_PRODUCTID])
    )
)

 

Replace table and columns names with your owns

View solution in original post

6 REPLIES 6
Bibiano_Geraldo
Super User
Super User

Hi @duane1 ,

Create a new calculated column using this DAX:

TO_COUNT2 = 
CALCULATE(
    SUM(TableName[FROM_COUNT2]),
    FILTER(
        TableName,
        TableName[TO_PRODUCTID] = EARLIER(TableName[FROM_PRODUCTID])
    )
)

 

Replace table and columns names with your owns

Thanks, this is what worked.  I received the same help from another.  

Anonymous
Not applicable

Hi @duane1 ,

Would you like to achieve the following results?

1.png

Please try to add a new column and use the code below.

 

TO_COUNT2 = 
CALCULATE(
    SUM(TEST[FROM_COUNT2]),
    FILTER(
        TEST,
        TEST[TO_PRODUCTID] = EARLIER(TEST[FROM_PRODUCTID])
    )
)

 

Could you please provide example data or sample files here if you have any confused? We could offer you more help if we have information in detail. There is sensitive data that can be removed in advance. How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Thanks for your understanding. Your time and cooperation are much valued by us. We are looking forward to hearing from you to assist further.

Best regards,

Lucy Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Thanks, this worked.  I had a feeling EARLIER was involved.  I was learning about it.  This is the solution.

EARLIER is a legacy function, and not recommended. Use variables.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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