powerbipowerquery

Slicing multiple fact tables with shared attributes


I am a beginner at Power BI and PowerQuery and have a question regarding dimension tables.

I have a report summarising testing results across several different test systems for a product. Each test is done on a certain component of each product, so has attributes structured like so:

And here are two examples of the fact tables containing test results.

ELECTRICAL TEST

Batch ID Sample ID Component ID Time (s) Voltage (V)
1 1 A 1 8.43
1 1 A 2 8.52

MECHANICAL TEST

Batch ID Sample ID Component ID Time (s) Displacement (mm)
1 1 A 1 10.42
1 1 A 2 11.53

I want to have slicers that can filter all charts by batch ID, sample ID and component ID. So far I have been creating separate dimension tables for each of these, and creating a one to many relationship with the fact tables, but this results in very short single column tables e.g.

COMPONENT IDS

Component ID
Component A
Component B
Component C
Component D

Is this the correct approach or should I be using a many to many relationship or some other method?


Solution

  • Your solution works perfectly and is part of PBI best practicies (Star Schema). In your situation you only have 3 variables in your Fact tables, so creating 3 Dim tables is easy, but if you have a lot of variables it can be more complicated. I will present you one strategy based on your example but this can be extended to any case in the same context.

    You can follow these steps to accelerate the process and getting only one Dim table:

    in ELECTRICAL TEST table add the following DAX column:

    Key = 'ELECTRICAL TEST'[Batch ID] & 'ELECTRICAL TEST'[Sample ID] & 'ELECTRICAL TEST'[Component ID]
    

    & in MECHANICAL TEST table add the following DAX column:

    Key = 'MECHANICAL TEST'[Batch ID] & 'MECHANICAL TEST'[Sample ID] & 'MECHANICAL TEST'[Component ID]
    
    DimTEST = SUMMARIZE(
                        UNION(
                              SUMMARIZE('ELECTRICAL TEST',
                                        'ELECTRICAL TEST'[Batch ID],
                                        'ELECTRICAL TEST'[Sample ID],
                                        'ELECTRICAL TEST'[Component ID],
                                        'ELECTRICAL TEST'[Key]),
                              SUMMARIZE('MECHANICAL TEST',
                                        'MECHANICAL TEST'[Batch ID],
                                        'MECHANICAL TEST'[Sample ID],
                                        'MECHANICAL TEST'[Component ID],
                                        'MECHANICAL TEST'[Key])
                             ),
                        [Batch ID],
                        [Sample ID],
                        [Component ID],
                        [Key]
                        ) 
    

    What we are doing here is just grouping the Fact tables by filters and keys, unioning them and then grouping the result by filters and key to avoid duplicates, getting the desired DimTEST table.

    You can now use this DimTEST table to filter the visuals as desired.

    The following part is only my interpretation of this method, It would be great if other PBI users can add more information and their thoughts on this methodology. Also you will need to test the performance (and eventually the loss of performance) compared to the classical Star Schema.

    PROS:

    CONS: