Forum Discussion
Sumif / DAX
I am relatively new in power BI and not sure how to get the following results in power bi. Can someone help
β
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
________________________
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 π
4 Replies
- FowmySuper 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
________________________
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 π
- AdilDawoodNew Member
Thanks for the solution
- Ashish_MathurSuper User
- AdilDawoodNew Member
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.