I have a data model and measure where I am reporting on the number of items in stockrooms that were *not* ordered in the last x days. It works, but the Power Pivot table is not paying attention to one of the filters and I don't understand filter context well enough to understand why. Apologies for the long post, but the spreadsheet is massive and proprietary so I will try to illustrate the setup by this description.
In simplified form I have 3 tables: ManagedBy - 1:many - Storeroom - 1:many - OrderHistory.
ManagedBy has
Storeroom Manager
--------- --------
009G Internal
118L Vendor
047E Vendor
Storeroom and ManagedBy are linked by Storeroom
Storeroom has
Business Unit Location Item Unit PrimaryKey
------------- -------- ---- ---- ----------
Hospital 1 009G 25052 Box 009G_25052_Box
Hospital 1 118L 13452 Case 118L_13452_Case
Hospital 2 A100 33245 Roll A100_33245_Roll
Hospital 3 047E 25052 Each 047E_25052_Each
Storeroom IDs are unique across the organization so Business Unit is not needed in the primary key
OrderHistory and Storeroom are linked by PrimaryKey-ForeignKey
OrderHistory has
Business Unit Location Item Unit ForeignKey OrderDate OrderQty
------------- -------- ---- ---- ---------- --------- --------
Hospital 1 009G 25052 Box 009G_25052_Box May 12 3
Hospital 1 118L 13452 Case 118L_13452_Case May 12 4
Hospital 2 A100 33245 Roll A100_33245_Roll May 12 1
In this simple example I want to report on item 25052 in location 047E that does not have any orders associated with it. My measure is:
Zero Orders:=
IF (
ISBLANK (
CALCULATE ( COUNTROWS ( 'OrderHistory' ), 'Order History'[OrderQty] > 0 )
),
0,
CALCULATE ( COUNTROWS ( 'OrderHistory' ), 'Order History'[OrderQty] > 0 )
)
and I filter the pivot table by clicking on the row header to show only the zero items.
(Rows can get into the OrderHistory table without any order qty for various reconciliation purposes which is why I have to test for the OrderQty actually being positive.)
I have a timeline to filter the OrderHistory[OrderDate] field and slicers to filter by Storeroom[Business Unit] and Storeroom[Storeroom], which work great. However, if I add a slicer for the ManagedBy[Manager] field, the pivot table ignores the slicer selection. (Ditto if I add the field directly to the pivot table filter section.)
So, I'm trying to understand why the Manager slicer is being ignored - is it something about the part of the measure that forces the zero values? I am able to filter on the Manager field for most other similar pivot tables so that's my guess. I will also be adding another lookup table at the same level as the ManagedBy table - an item master field that will give me the start date for items, so that I can exclude zero-order items that were added to a storeroom sometime after my earliest selected OrderDate. So I need to resolve this problem before I do that.
Thanks for your help.
In simplified form I have 3 tables: ManagedBy - 1:many - Storeroom - 1:many - OrderHistory.
ManagedBy has
Storeroom Manager
--------- --------
009G Internal
118L Vendor
047E Vendor
Storeroom and ManagedBy are linked by Storeroom
Storeroom has
Business Unit Location Item Unit PrimaryKey
------------- -------- ---- ---- ----------
Hospital 1 009G 25052 Box 009G_25052_Box
Hospital 1 118L 13452 Case 118L_13452_Case
Hospital 2 A100 33245 Roll A100_33245_Roll
Hospital 3 047E 25052 Each 047E_25052_Each
Storeroom IDs are unique across the organization so Business Unit is not needed in the primary key
OrderHistory and Storeroom are linked by PrimaryKey-ForeignKey
OrderHistory has
Business Unit Location Item Unit ForeignKey OrderDate OrderQty
------------- -------- ---- ---- ---------- --------- --------
Hospital 1 009G 25052 Box 009G_25052_Box May 12 3
Hospital 1 118L 13452 Case 118L_13452_Case May 12 4
Hospital 2 A100 33245 Roll A100_33245_Roll May 12 1
In this simple example I want to report on item 25052 in location 047E that does not have any orders associated with it. My measure is:
Zero Orders:=
IF (
ISBLANK (
CALCULATE ( COUNTROWS ( 'OrderHistory' ), 'Order History'[OrderQty] > 0 )
),
0,
CALCULATE ( COUNTROWS ( 'OrderHistory' ), 'Order History'[OrderQty] > 0 )
)
and I filter the pivot table by clicking on the row header to show only the zero items.
(Rows can get into the OrderHistory table without any order qty for various reconciliation purposes which is why I have to test for the OrderQty actually being positive.)
I have a timeline to filter the OrderHistory[OrderDate] field and slicers to filter by Storeroom[Business Unit] and Storeroom[Storeroom], which work great. However, if I add a slicer for the ManagedBy[Manager] field, the pivot table ignores the slicer selection. (Ditto if I add the field directly to the pivot table filter section.)
So, I'm trying to understand why the Manager slicer is being ignored - is it something about the part of the measure that forces the zero values? I am able to filter on the Manager field for most other similar pivot tables so that's my guess. I will also be adding another lookup table at the same level as the ManagedBy table - an item master field that will give me the start date for items, so that I can exclude zero-order items that were added to a storeroom sometime after my earliest selected OrderDate. So I need to resolve this problem before I do that.
Thanks for your help.