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
Anonymous
Not applicable

Subtracting based on a range of values - URGENT HELP !!!

Hello all,

     I have two matrix visualizations like this,

 

2.JPG

 

 

The values for both the matrix visuals are taken from a single table.

 

I want to subtract the values of both the sub-totals. But, keeping the 1st matrix's total as it is, say 190 and I want to select a range and sum the values, for example, for the account numbers 4 to 6, the summed up values will be 10+20+30 = 60. 

Then, I need to subtract the 190 (Sum of Matrix 1) with 60 (Sum of Matrix 2).

190 - 60 = 130.

 

Finally, that result 130 should be displayed in the 2nd Matrix itself or another matrix.

How can I achieve this?

 

I tried to achieve this with a slicer, it is not working as I expected. Could anyone please help to resolve this?

 

Sample Files are given below,


pbix_1

pbix_2

excel file

 

 

Thanks in Advance,

Praveen.

 

2 ACCEPTED SOLUTIONS

@Anonymous try this:

 

Total Difference = 
CALCULATE(
SUM(Table[Amount]), 
ALL( Table ) 
)
-
CALCULATE(
SUM(Table[Amount]),
Table[Account] IN {4,5,6}
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

Table[Account] >= 4 && Table[Account] <= 6

 

replace the IN condition with above logic to check the range. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

8 REPLIES 8
parry2k
Super User
Super User

@Anonymous so if i understood your requirement correctly , you want to subtract value of selected account (in a slicer) from total amount, correcT?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Anonymous is this range fixed? Always 4 to 6?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Anonymous try this:

 

Total Difference = 
CALCULATE(
SUM(Table[Amount]), 
ALL( Table ) 
)
-
CALCULATE(
SUM(Table[Amount]),
Table[Account] IN {4,5,6}
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thank you very much for your kindl response. But, if this range is high, say for instance if I have to select the values between the ranges of 40000 to 90000 out of 1 million accounts, how can I select, what could be the DAX for selecting this kind of ranges?

 

Regards,

Praveen.

Table[Account] >= 4 && Table[Account] <= 6

 

replace the IN condition with above logic to check the range. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Awesome!!! Thank You very much.

 

Regards,

Praveen.

Anonymous
Not applicable

Yes this range is fixed.

Anonymous
Not applicable

Hi Parry,

     No. The slicer one is the example which i have tried myself. The actual requirement is, I need to subtract between both the matrices subtotal.

 

Sample PBIX file

 

2.JPG

 

 

 

1st matrix values are as it is coming from the source.

2nd matrix's value should be a range of selected values using DAX. say for ex,the sum of values of account numbers 4 to 6.

 

1.JPG

 

Sum of 1st matrix - sum of 2nd matrix (with the selected Range of values) = Result should be displayed on the second  matrix.

 

190 - 60 = 130

 

Thanks for your reply,

Praveen.

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.