Return a subset of assets based on related criteria

robertarm

New Member
Joined
Sep 3, 2015
Messages
4
Hi guys,
I don't even know if this is a power pivot question or something able to be accomplished just in excel but I haven't been able to find a solution so far.
I have a list of work orders with all relevant info (standard job, comments, work order number, plant number etc.) What I want to be able to do is filter for all of the assets which have a workorder with a specific standard job, but then return all work orders attached to these assets not just the the ones with this job code.
All of the info is in a flat table at the moment in a single excel sheet (extracted from other databases into .xls format).
The standard job I want to filter on will be different each time (There is a finite number of options, maybe 40), but I would like the sheet to be able to be easily manipulated by people who are not even close to being excel power users.
Ideally I would like it to return a pivot table listing all of the assets, the various standard jobs so these can be summed, but most importantly be able to be expanded from the pivot table to return the full list of filtered results so they can be used to issue work and ensure when someone goes to an asset every job is issued efficiently.

Excel 2010
ABCDEFG
1Work GroupWork Order NoPlant NoWork Order DescStandard Job NoStandard Job DescComments
2CHOXPM104316305DS00501Replace DOF Assembly1DOFSWReplace DOF Assemblyinsulation on drop out fuses perished
3CHOXPM104354555DS00547Oil Stain1OILSTOil StainOIL STAIN ON BOTTEM EDGE OF SUB
4CHOXPM104442514DS00566Replace DOF Assembly1DOFSWReplace DOF Assemblyroadside expulsion fuse deteriorated
5CHOXPM104401307DS00593Oil Leak1OILLEOil Leakoil leak from drain
6CHOXPM103654611DS00629Oil Leak1OILLEOil Leakchek oil leack at tap and at top of sub
7CHOXPM104542591DS00658Replace DOF Assembly1DOFSWReplace DOF Assemblydof fuses perrished
8CHOXPM104691703DS007273x expulsion fuses deteriorated1DOFSWReplace DOF Assembly
9CHOXPM103642707DS00756Vermin1VERMNVerminbirds nesting
10CHOXPM103958717DS00760Oil Leak1OILLEOil Leakrepair oil leak
11CHOXPM104448138DS00861Replace DOF Assembly1DOFSWReplace DOF Assemblyexpulsion fuses x 2 deteriorated
12CHOXPM103855113DS01353Oil Stain1OILSTOil Stainoil stain at drain plug
13CHOXPM103855114DS01353Replace Surge Diverter1SURGEReplace Surge Diverterold red insulators require replaceing
14CHOXPM104318027DS01543Repair/Replace HV Hardware1HVHARRepair/Replace HV HardwareTYPE: Distribution Substation UG , ASSET NO: 1543 , DESCRIPTION: UG Dist Sub 1543, Padmount HV Switchgear , LOCATION: Roony Ave, Abbotsbury 2176 Switchgear moves excessively when operated-requires resecuring to plinth Passed on to Brendan Leshone
15CHOXPM104518812DS01714Replace DOF Assembly1DOFSWReplace DOF Assemblyreplace degraded drop out fuses
16CHOXPM104528990DS01714Replace DOF Assembly1DOFSWReplace DOF Assemblyreplace degraded drop out fuses
17CHOXPM103688963DS01873Oil Leak1OILLEOil Leakoil leak Contestable Works advised sub will be replaced under URS project in June 2015
18CHOXPM103698639DS01879Oil Leak1OILLEOil Leakoil leak on sub
19CHOXPM103932426DS01879REPLACE HV CROSSARM1HVARMReplace HV Crossarm
20CHOXPM104518801DS01946Replace DOF Assembly1DOFSWReplace DOF Assemblyreplace degrade drop out fuses
21CHOXPM103620714DS02275Oil Leak1OILLEOil LeakOIL LEAK FROM SUB 2275
22CHOXPM103934712DS02275REPLACE HV CROSSARM1HVARMReplace HV Crossarm
23CHOXPM103547607DS02403Oil Leak1OILLEOil Leakoil stain on sub
24CHOXPM103931960DS02403REPLACE TRANSFORMER1TXREPReplace Transformer
25CHOXPM103932388DS02403REPLACE HV CROSSARM1HVARMReplace HV Crossarm
26CHOXPM104012529DS02458Repair/Replace HV Hardware1HVHARRepair/Replace HV Hardwarereplace drop out fuses
27CHOXPM103769406DS02750Replace Surge Diverter1SURGEReplace Surge Diverterold style brown serg diverter
28CHOXPM103183383DS02929Repair/Replace ABS Arcing Horn1ABSAHRepair/Replace ABS Arcing Hornarching horn needs removing
29CHOXPM104316310DS03042Replace DOF Assembly1DOFSWReplace DOF Assemblydrop out fuses insulation frayed
30CHOXPM103596589DS03325Oil Leak1OILLEOil Leakcheck oil leak
31CHOXPM103931937DS03325REPLACE TRANSFORMER1TXREPReplace Transformer
32CHOXPM103659010DS03338Oil Leak1OILLEOil Leaklight oil leak
33CHOXPM103932406DS03338REPLACE BROKEN MDI UNIT1MDIUNReplace Broken MDI Unit
34CHOXPM103659026DS03341Repair/Replace LV Hardware1LVHARRepair/Replace LV Hardwaremeter box wire hanging out of sub
35CHOXPM103748162DS03581Replace HV Insulator1HVINSReplace HV Insulatorreplace chipped insulator

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1




I'm running Excel 2010 on Windows 7.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Sure,
If I filter a pivot table for standard job 1HVARM. I get 3 results

Excel 2010
ABC
1Standard Job No1HVARM
2
3
4Plant NoWork Order NoWork Order Desc
5DS0187903932426REPLACE HV CROSSARM
6DS0227503934712REPLACE HV CROSSARM
7DS0240303932388REPLACE HV CROSSARM
8Grand Total

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet8



However I want to see all wokorders for the 3 assets which have a workorder with this standard job (I have applied the filter to the assets below for this example, but in my full sheet there are 40,000 WO's and 30,000 assets so it isn't a realistic option this way).

Excel 2010
ABC
3
4Plant NoWork Order NoWork Order Desc
5DS0187903698639Oil Leak
603932426REPLACE HV CROSSARM
7DS0227503620714Oil Leak
803934712REPLACE HV CROSSARM
9DS0240303547607Oil Leak
1003931960REPLACE TRANSFORMER
1103932388REPLACE HV CROSSARM
12Grand Total

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet8
 
Upvote 0
Interesting problem!

The core of the problem is that you want to select a Standard Job No, and filter your PivotTable not just to those Standard Job Nos but to all Plant Nos that have a work order with that Standard Job No. This means a filter directly on the Standard Job No column won’t work.

I’ve uploaded a file with a sample solution (Excel 2010 PowerPivot):
https://drive.google.com/file/d/0B9pNjpDQKy_LM09KMjdaM2N4N1k/view?usp=sharing

My method is to create a second table containing Standard Job Nos, relate your main table to it using an inactive relationship, use a slicer on this lookup table to select a the Standard Job No, then use DAX to create a measure that is used to filter Plant No.

The end result is that the user just selects a Standard Job No on a slicer and the PivotTable filters as you’ve described.

These are the steps I followed:

  1. Create a “Standard Job Number Selection” lookup table that contains distinct Standard Job Nos (and descriptions if you want). I have done this manually but you should use Power Query or similar.
  2. Add a relationship from your main table’s “Standard Job No” column to the Standard Job No Selection column in the new table.
  3. Mark this relationship as inactive, so that it doesn’t automatically filter your PivotTable.
  4. Create a PivotTable with the row labels you require, including at least Plant No. I’ve included Plant No, Work Order No & Work Order Desc as per your example.
  5. Add a slicer for the “Standard Job No Selection” column from the “Standard Job Number Selection” table.
    At this stage, the PivotTable will still be unfiltered, showing all work orders.
  6. Create a measure which will act as a flag indicating whether to include the current plant. This measure will return 1 only if there is a single plant present in the filter context and that plant has at least one work order with the selected Standard Job No. The red CALCULATETABLE section creates the list of “valid” plants by using the inactive relationship to filter the main table. The VALUES ( Data[Plant No] ) in green gives us the list of plants in the current context (which is just a single plant at a time in the PivotTable I have set up). The IF(HASONEVALUE(...)) will be evaluated in the context of the intersection of the red and the green, which will be the current plant only if it is “valid”, in which case the measure will return 1, otherwise blank.
    Code:
    [COLOR=#000000][B]Flag - Single Plant has Selected Standard Job[/B] :=
    CALCULATE (
        IF ( HASONEVALUE ( Data[Plant No] ), 1 ),[/COLOR]
        [COLOR=#008000]VALUES ( Data[Plant No] ),[/COLOR]
        [COLOR=#ff0000]CALCULATETABLE (
            VALUES ( Data[Plant No] ),
            ALL ( Data ),
            USERELATIONSHIP ( Data[Standard Job No], StandardJobNumberSelection[Standard Job No Selection] )
        )[/COLOR]
    )
    <strike></strike>
  7. In the PivotTable, filter the Plant No column (drop-down or right-click Filter) by selecting Value Filter: “Flag – Single Plant has Selected Standard Job” equals 1.
  8. Now if you select one (or more) Standard Job Nos on the slicer, the PivotTable will be filtered appropriately.
  9. Note: In case you later want to add a separate filter on Plant No (e.g. a slicer to further limit the plants you are looking at), go into PivotTable options and enable “Multiple Filters per Field”.
 
Upvote 0
Interesting problem!

Hi Ozeroth,
these were my thoughts as well. Tried to find a Power Query solution for it and failed.

Now reading your Power Pivot solution on it was a real eye opener: If I could only get my head around these context things in DAX (they still are a moving target for me): What an elegant solution to come up with!
This really motivated me to get back into DAX.

But on the other hand, the description you’ve provided ordered some thoughts and made the Power Query solution appear:

let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
Merge = Table.NestedJoin(Source,{"Plant No"},Source,{"Plant No"},"NewColumn",JoinKind.Inner),
Expand = Table.ExpandTableColumn(Merge, "NewColumn", {"Standard Job No", "Standard Job Desc"}, {"Standard Job No.1", "Standard Job Desc.1"})
in
Expand

So you simply load the table and join it with itself on Plant No: The column whose matches on shall be returned. Then expand on the Job No’s and descriptions to show: Done.

... thought that this will make you smile :)

Thank you!

LinkToFile
 
Upvote 0
Hi Imke,
Glad to have motivated you back to DAX!
I like the simplicity of your "join the table with itself" method - not something I would have thought of :)

robertarm - I would be interested in how large a table you end up with following Imke's method on your full dataset. Is either method preferable in your situation?

All the best!
 
Upvote 0
Ozeroth and Imke,
thanks for your feedback it is greatly appreciated.
I was starting to think I would have to get creative with VBA to push out a solution for me.

I have so far implemented Ozeroth's solution on my full sized table I currently have which is only 8000 records and it all works fine. My system does lag for 5 seconds or so with some operations when you play with the table, but overall not something I am hugely concerned with. I will wait and see how it goes on the full list of 40,000 if I ever need to run it on that table.

I don't fully understand the solution but can decipher most of it (I only got powerpivot recently so I could get distinct count in a few tables I needed and have been having a bit of a play since then) from other reading I was doing trying to find a solution to this myself. I found nothing which brought me close to this, but it is a hard problem to find the right search term for,

ImkeF, thanks for your input too. Unfortunately I can't access your file because it is asking me for a username and password to a live account.
I actually put powerquery on also hoping there would be an elegant out of the box solution for what I wanted but there was nothing and it appeared to be very foreign to me and wasn't intuitive to me at all.
What does that query actually do and how do you do the final sorting etc?

At the end of the day I need this to produce a pivot table/table for people far less excel savvy than myself (and primates compared to what you 2 have proven) who really are only basic excel users so simplifying the final product for them to chop and change their filters for different standard job numbers is the main objective for me.
Ultimately the data for this will be a daily update using cognos from our corporate database. I am currently getting this dumped in xls for ease of use but will have to find a way for this filterable table to look up that info.

Again, thank you very much for your input in getting me to this point where I have something which works.

If you have some pointers on which solution would be optimal going forward on the additional info please let me know, but what I have already does what I need.
 
Upvote 0
I have just found one limitation.
I can't drill through the table to export all of the details on every WO to a new sheet as you would in a normal pivot table.

Doing that just exports everything unfiltered.
Is there a way to handle this?
Is Imke's solution better to handle this? but I still have the questions above around usability for the general public.
 
Upvote 0
Sorry about the link, wasn't aware of the limitation.
Try this one please: http://www.thebiccountant.com/download/456/

For the drilldown you need a measure in your pivottable. I've included it in my solution. (Also the Grand Total for all of them)

I'm expecting the filtering on the JobNo to be very fast, but have not tested it - so I would very much welcome your feedback on this :)

Loading the updated Input data into the model should take longer than Ozeroths, because the Power Query calculation has to be done as well, but once this is done - at least in theory - it should be very fast.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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