Proper use of ALLSELECTED?

macfuller

Active Member
Joined
Apr 30, 2014
Messages
319
Office Version
  1. 365
Platform
  1. Windows
I have the following measure which is returning 100% for every row.

Voucher Spend as Pct of GL:=
[Voucher Amt] / CALCULATE ( [Voucher Amt], ALLSELECTED ( Vouchers[Account] ) )

Voucher Amt:=SUM(Vouchers[Voucher Amount])

What I would like is for when I select certain accounts that the measure return what % of the visible total is showing.

At the top level I have an 'Account Tree' lookup table with an 'Account' column all the organization's GL accounts. A column in this table, NODE 7, identifies the GL accounts for Medical Supplies, Dietary Supplies, and so on. I have a slicer selecting "Medical Supplies" to give me the preferred list of GL accounts.

In between I have the 'Purchase Order' table. Each line of a PO has a GL Account, to which the 'Account Tree' links the Account field.

Then comes the Voucher table linked many:1 with the PO table. The Voucher table also has an Account field and the 'Voucher Amount' field with the spend on the PO item.

So when I select the "Medical Supplies" NODE 7 category in the slicer I want to list all the Medical Supply GL Accounts, their Voucher Amt, and the % of the overall Voucher spend on Medical Supply accounts. So I would like to get:


AccountVoucher AmtVoucher Spend as Pct
Antiseptics$1,50037.5%
Catheters$1,00025%
Oxygen$1,50037.5%
Total$4,000100%

<tbody>
</tbody>


I have tried changing the ALLSELECTED ( ) portion of the CALCULATE statement to do the 'Account Tree'[Account], 'Purchase Orders'[Account], and 'Voucher'[Account] but in all cases each row returns 100% so I'm obviously not understanding the correct use.

Thanks for your help.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Sorry, I figured this out once I understood the source my confusion. My pivot table was displaying rows based on the GL Account description, not on the 4-digit account code itself that I was filtering on. Once I changed ALLSELECTED ( 'Account Tree'[Description]) the pivot table behaves as expected.

I constantly struggle, even if no one else does, with thinking that because I have filtered certain rows of the data via a slicer then filters within a measure will recognize any rows that are filtered rather than those that are specifically named, even if from the same table. There may be a DAX expression to recognize filters like that, just not ALLSELECTED...
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top