How to use 'wildcards' across data model connections

pjmorris

Well-known Member
Joined
Aug 2, 2012
Messages
2,172
Office Version
  1. 365
Platform
  1. Windows
This problem follows on from a previous discussion (Use of Multiple 'USERELATIONSHIP' in a single measure) (Rory, thank you).

The problem is that I wish to avoid creating a calculated field to link the dimension table and the fact table. This is because, based on my calculations, the dimension table would have something in excess of 4.5M rows - and it slow enough at the moment with 120K lines.

I have created an example spreadsheet, but don't know how to attach it!. The relevant parts are below:

1. The Fact Table:
DIDCompanyWBSValue
E205NOV5051
E205NOV5052
E205NOV5054
E205NOV5058
ILS018NOV50516
ILS018NOV10032
ILS018ALF10048
ILS018ALF50564
ENG207ALF50580
ENG207ALF50596
ENG207ALF100112
ENG207ALF100128


2. The Dimension Table: The key thing here is to note that two of the fields are blank (unspecified) and are highlighted in pink.
GroupDIDCompanyWBS
GandalfE205NOV505
MorrisILS018100
BugginsENG207ALF


3. Required Output is:
Expected ResultsResults
Gandalf15
Morris80
Buggins416


4. Data Model. Using Powerquery to create relevant intermediary tables from the Fact Table:
1641315029956.png


5. The Measure defined to achieve the results and the resulting output:
Power Query:
=CALCULATE(SUM(qryTable1[Value]), qryTable2)

Row Labelssums
Abbas15
Merritt
Morris
Grand Total15


Problem:

It would appear that in applying the filters across the 3 intermediary tables (needed to handle the many-to-many relationships between the Fact and Dimension tables), where no data is provided in the pink cells this is being interpreted literally. What I would like it to do is simply ignore that filter condition and in effect apply a wildcard or 'any' criteria.

But I don't know how to do so.

Any ideas very gratefully received.

Regards

Peter
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Power Query:
let
    Fact = Excel.CurrentWorkbook(){[Name="Fact"]}[Content],
    tbl1 = Table.Group(Fact, {"DID","WBS"}, {{"Results", each List.Sum([Value]), type number}}),
    Dim = Table.SelectColumns(Excel.CurrentWorkbook(){[Name="Dimension"]}[Content],{"Group", "DID","WBS"}),
    tbl2 = Table.NestedJoin(tbl1, "DID", Dim, "DID", "All"),
    tbl3 = Table.ExpandTableColumn(tbl2, "All", {"Group","WBS"}, {"Group","WBS1"}),
    tbl4 = Table.SelectRows(tbl3, each [WBS1] = null or [WBS]= [WBS1]),
    Result = Table.Group(tbl4, {"Group"}, {{"Results", each List.Sum([Results]), type number}})
in
    Result

Book2
ABCDEFGH
1DIDCompanyWBSValueGroupResults
2E205NOV5051Gandalf15
3E205NOV5052Morris80
4E205NOV5054Buggins416
5E205NOV5058
6ILS018NOV50516
7ILS018NOV10032
8ILS018ALF10048
9ILS018ALF50564
10ENG207ALF50580
11ENG207ALF50596
12ENG207ALF100112
13ENG207ALF100128
14
15
16GroupDIDCompanyWBS
17GandalfE205NOV505
18MorrisILS018100
19BugginsENG207ALF
20
Sheet1
 
Upvote 0
Power Query:
let
    Fact = Excel.CurrentWorkbook(){[Name="Fact"]}[Content],
    tbl1 = Table.Group(Fact, {"DID","WBS"}, {{"Results", each List.Sum([Value]), type number}}),
    Dim = Table.SelectColumns(Excel.CurrentWorkbook(){[Name="Dimension"]}[Content],{"Group", "DID","WBS"}),
    tbl2 = Table.NestedJoin(tbl1, "DID", Dim, "DID", "All"),
    tbl3 = Table.ExpandTableColumn(tbl2, "All", {"Group","WBS"}, {"Group","WBS1"}),
    tbl4 = Table.SelectRows(tbl3, each [WBS1] = null or [WBS]= [WBS1]),
    Result = Table.Group(tbl4, {"Group"}, {{"Results", each List.Sum([Results]), type number}})
in
    Result

Book2
ABCDEFGH
1DIDCompanyWBSValueGroupResults
2E205NOV5051Gandalf15
3E205NOV5052Morris80
4E205NOV5054Buggins416
5E205NOV5058
6ILS018NOV50516
7ILS018NOV10032
8ILS018ALF10048
9ILS018ALF50564
10ENG207ALF50580
11ENG207ALF50596
12ENG207ALF100112
13ENG207ALF100128
14
15
16GroupDIDCompanyWBS
17GandalfE205NOV505
18MorrisILS018100
19BugginsENG207ALF
20
Sheet1
Hi, firstly apologies for being so slow to reply.

This needs to be a Powerpivot solution rather than Powerquery as its the dynamic part of the data model. I'm currently now a multilayered data model (snowflake style), but other work problems are halting progress. If I can't get that to work I'll obviously give this approach a try.

Thank you for offering.

Regards

Peter
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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