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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AdilDawood
New Member

Sumif / DAX

I am relatively new in power BI and not sure how to get the following results in power bi. Can someone help

 

sumif-DAX.png

 

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@AdilDawood 

Go to Modeling Tab, click on New Table create a new table with the following code. This will list all the accounts from Both FROM and TO columns.

All Acounts = 
SELECTCOLUMNS(
    DISTINCT(
        UNION( VALUES(Accounts[From Account]), VALUES(Accounts[To Account]))
    ),
    "Account", Accounts[From Account]
)

 

Insert a Table B Visual and bring the Account field from the new table. Add the following measure.

 

Balance of Accounts = 

var _Acc = SELECTEDVALUE('All Acounts'[Account]) return
 
CALCULATE( SUM(Accounts[Amount]) , Accounts[To Account] = _Acc ) - 
CALCULATE( SUM(Accounts[Amount]) , Accounts[From Account] = _Acc )

 

Result

Fowmy_0-1608474470294.png

________________________

If my answer was helpful, please click Accept it as the solution to help other members find it useful

Click on the Thumbs-Up icon if you like this reply 🙂


Website YouTube  LinkedIn

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

4 REPLIES 4
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/

Thanks Ashish 

Although your solution does work for this data but this is a sample data and actual data is quite large. The solution provided by @Fowmy works better on that. 

Thanks anyway for the resposne. 

Fowmy
Super User
Super User

@AdilDawood 

Go to Modeling Tab, click on New Table create a new table with the following code. This will list all the accounts from Both FROM and TO columns.

All Acounts = 
SELECTCOLUMNS(
    DISTINCT(
        UNION( VALUES(Accounts[From Account]), VALUES(Accounts[To Account]))
    ),
    "Account", Accounts[From Account]
)

 

Insert a Table B Visual and bring the Account field from the new table. Add the following measure.

 

Balance of Accounts = 

var _Acc = SELECTEDVALUE('All Acounts'[Account]) return
 
CALCULATE( SUM(Accounts[Amount]) , Accounts[To Account] = _Acc ) - 
CALCULATE( SUM(Accounts[Amount]) , Accounts[From Account] = _Acc )

 

Result

Fowmy_0-1608474470294.png

________________________

If my answer was helpful, please click Accept it as the solution to help other members find it useful

Click on the Thumbs-Up icon if you like this reply 🙂


Website YouTube  LinkedIn

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy 

Thanks for the solution

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors