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:


[TABLE="width: 500"]
<tbody>[TR]
[TD]Account[/TD]
[TD]Voucher Amt[/TD]
[TD]Voucher Spend as Pct[/TD]
[/TR]
[TR]
[TD]Antiseptics[/TD]
[TD]$1,500[/TD]
[TD]37.5%[/TD]
[/TR]
[TR]
[TD]Catheters[/TD]
[TD]$1,000[/TD]
[TD]25%[/TD]
[/TR]
[TR]
[TD]Oxygen[/TD]
[TD]$1,500[/TD]
[TD]37.5%[/TD]
[/TR]
[TR]
[TD]Total[/TD]
[TD]$4,000[/TD]
[TD]100%[/TD]
[/TR]
</tbody>[/TABLE]


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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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