Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
catfood49
Frequent Visitor

Customer SCD2 Activity over Current & Old Records

Hi all

 

I have a Customer Dimension table (SCD2), a Sales Fact table, and Product Dimension table:

 

I want to do analysis on users who have bought both a Shirt, and some Shorts.

 

Customer ID A bought both a Shirt and Shorts but as the Dimension record changed over time the Customer Keys are recorded are 1 and 4.

 

What Measure(s) would I need to do to capture that they have bought both?

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @catfood49,

 

Suppose you have created relationships between these three tables.

1.PNG

Create a calculated table. (in my test, it's named as Table1) Also, in this table, add a new calculated column.

Table1 =
FILTER (
    SELECTCOLUMNS (
        'Fact Sale',
        "Customer Name", RELATED ( 'Dim Customer'[Customer ID] ),
        "Product Name", RELATED ( 'Dim Product'[Site Name] )
    ),
    [Product Name] = "Shirt"
        || [Product Name] = "Shorts"
)

Count =
CALCULATE (
    DISTINCTCOUNT ( Table1[Product Name] ),
    ALLEXCEPT ( Table1, Table1[Customer Name] )
)

Based on Table1, create an other calculated table.

Table2 = FILTER(Table1,Table1[Count]=2)

You can get below result.

2.PNG

 

Regards,
Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @catfood49,

 

Suppose you have created relationships between these three tables.

1.PNG

Create a calculated table. (in my test, it's named as Table1) Also, in this table, add a new calculated column.

Table1 =
FILTER (
    SELECTCOLUMNS (
        'Fact Sale',
        "Customer Name", RELATED ( 'Dim Customer'[Customer ID] ),
        "Product Name", RELATED ( 'Dim Product'[Site Name] )
    ),
    [Product Name] = "Shirt"
        || [Product Name] = "Shorts"
)

Count =
CALCULATE (
    DISTINCTCOUNT ( Table1[Product Name] ),
    ALLEXCEPT ( Table1, Table1[Customer Name] )
)

Based on Table1, create an other calculated table.

Table2 = FILTER(Table1,Table1[Count]=2)

You can get below result.

2.PNG

 

Regards,
Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thats great, @v-yulgu-msft.

I'm tying what I asked into some other things so don't have everything I need yet but this has definitely got me going.

Thanks very much.

Greg_Deckler
Super User
Super User

Depends on what you want to do with it, but here would be one way to identify those customers.

 

Create the following measures:

 

CountOfShirts = CALCULATE(COUNTROWS('Fact Retail Sale'),FILTER('Fact Retail Sale','Fact Retail Sale[Product Key]=1))

CountOfShorts = CALCULATE(COUNTROWS('Fact Retail Sale'),FILTER('Fact Retail Sale','Fact Retail Sale[Product Key]=3))

Put these measures into a table along with Customer ID. Filter CountOfShirts and CountOfShorst to > 0


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.