Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
3 years ago
Solved

Correlative account

Hello

I have a file with correlates that correspond to a client, this can contain a correlative with 1 single line or it can be repeated for example

Client 1 buy LPN 1

Client 2 buy LPN 1

Client 2 buy LPN 2

The first customer I buy only 1 time and one line, customer 2 I buy 1 time but I buy 2 lines, I can have many customers with those conditions and what I need is to be able to count those customers according to those purchases.

It would have something like this: 20 Customers buy 1 product, 30 customers buy 2 products etc.

  • bolfri's avatar
    bolfri
    3 years ago

    Isn't that the solution that I've provided?

     

    Based on the Sample Data we have:

    1 customer with 1 line.

    2 customers with 2 lines.

    Since the Number of transactions is the column in the dim_client table you can use it on graph.

     

4 Replies

  • bolfri's avatar
    bolfri
    Icon for Solution Sage rankSolution Sage

    Data preparing

    fact_transaction table contains all the transactions (each row is a transaction)

    Model preparing

    Create a new calculated table:

    dim_client = DISTINCT(fact_transaction[Client])

    dim_client holds all unique client from your fact_transaction data

    Relationships

    Connect dim_client[Client] to fact_transaction[Client] by one to many.

    Modeling

    In the dim_client table create a new column:

     

    Number of transactions = CALCULATE( COUNTROWS(fact_transaction), RELATEDTABLE(fact_transaction) )

     

    Measures

    Number of customers = COUNTROWS(dim_client)

     

    Final result:

    One customer made 1 transaction and 2 customers made 2 transactions. 

    I hope that was the case 🙂

     

     

     

  • Great I achieved it, now what I need and with this I finish, is the following.

    Since I have the account of each customer line I need to group in a summary table or in a graph in a percentage way how many customers have the same behavior.

    Occupying the example that I leave in the image, it is something like that.

    Customers with 16 Lines = 1

    Customers with 14 Lines = 1

    Customers with 13 Lines =2

    Customers with 12 Lines = 1

    Customers with 11 Lines = 3

    • bolfri's avatar
      bolfri
      Icon for Solution Sage rankSolution Sage

      Isn't that the solution that I've provided?

       

      Based on the Sample Data we have:

      1 customer with 1 line.

      2 customers with 2 lines.

      Since the Number of transactions is the column in the dim_client table you can use it on graph.