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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
User7664
Helper I
Helper I

Measure help. Removing an amount from the totals

Hi All

I have an matrix table that looks like the below.

 

The amount in Account 1 Sub Account B needs to subtracted away from Sub account A. The ledger system listed sub account b for reference only but it is already included in sub account a (i have no control over the data output). 

 

Sub Account A should equal 400,000 in Jan and 520,000 in Feb. The totals for account 1 in Jan should therefore be 400k and 520k for Feb. 

 

I cannot for the life of me work out how to do this with a measure. 

 

I've saved a sample PBIX file to gdrive. Any pointers would be great. 

 

Screenshot 2021-04-20 184115.png

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @User7664 

Please check the below picture and the sample pbix file's link down below.

The measure is in the sample pbix file.

 

Picture4.png

 

Account1 fix =
VAR subaccounta =
CALCULATE (
SUM ( 'Sample'[ Amount ] ),
'Sample'[Sub Account] = "Sub Account A"
)
VAR subaccountb =
CALCULATE (
SUM ( 'Sample'[ Amount ] ),
'Sample'[Sub Account] = "Sub Account B"
)
VAR account2 =
CALCULATE ( SUM ( 'Sample'[ Amount ] ), 'Sample'[Account] = "Account 2" )
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Sample'[Sub Account] ) = "Sub Account A", subaccounta - subaccountb,
SELECTEDVALUE ( 'Sample'[Sub Account] ) = "Sub Account B", BLANK (),
SELECTEDVALUE ( 'Sample'[Account] ) = "Account 1", subaccounta - subaccountb,
NOT ISFILTERED ( 'Sample'[Account] ),
account2 + subaccounta - subaccountb,
SUM ( 'Sample'[ Amount ] )
)

 

 

https://www.dropbox.com/s/nynsd9omaxzmu0r/Sample%202.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: https://www.linkedin.com/in/jihwankim1975/

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @User7664 

Please check the below picture and the sample pbix file's link down below.

The measure is in the sample pbix file.

 

Picture4.png

 

Account1 fix =
VAR subaccounta =
CALCULATE (
SUM ( 'Sample'[ Amount ] ),
'Sample'[Sub Account] = "Sub Account A"
)
VAR subaccountb =
CALCULATE (
SUM ( 'Sample'[ Amount ] ),
'Sample'[Sub Account] = "Sub Account B"
)
VAR account2 =
CALCULATE ( SUM ( 'Sample'[ Amount ] ), 'Sample'[Account] = "Account 2" )
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Sample'[Sub Account] ) = "Sub Account A", subaccounta - subaccountb,
SELECTEDVALUE ( 'Sample'[Sub Account] ) = "Sub Account B", BLANK (),
SELECTEDVALUE ( 'Sample'[Account] ) = "Account 1", subaccounta - subaccountb,
NOT ISFILTERED ( 'Sample'[Account] ),
account2 + subaccounta - subaccountb,
SUM ( 'Sample'[ Amount ] )
)

 

 

https://www.dropbox.com/s/nynsd9omaxzmu0r/Sample%202.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: https://www.linkedin.com/in/jihwankim1975/

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


User7664
Helper I
Helper I

Should this be done in the query editor? I think a measure is the best way?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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