Forum Discussion

Ranya's avatar
Ranya
Frequent Visitor
2 years ago
Solved

Create anew column

I have adata included two tables  Customer table included customer ID, customer name, state, city, country . Orders table included order ID, sales, profits, customer ID, date . I want to create a ...
  • Ranya's avatar
    2 years ago

    I have adata included two tables 

    Customer table included customer ID, customer name, state, city, country .

    Orders table included order ID, sales, profits, customer ID, date .

    I want to create a new column caculated the most 5 customers having sales .

  • Emantaha85's avatar
    2 years ago

    First,you need to Create a relationship between the Customer and Orders tables using the customer ID column.

    **Then create a measure for total sales:

    Total Sales = SUM(Orders[sales])

     

    and to rank customers by sales, you can use the following DAX measure:

    Customer Sales Rank = 

    RANKX(

        ALL(Customer),

        [Total Sales],

        DESC)

    To create the new column identifying the top 5 customers, you can add a calculated column to the Customer table:

     

    Top 5 Customer = 

    IF(

        [Customer Sales Rank] <= 5,

        "Top 5 Customer",

        "Other")

    To visualize this data:

    Select a bar chart  vidual with Customer[customer_name] on the  x axis and [Total Sales] as the value in y axis

    Add a visual level filter to the chart to only show where [Top 5 Customer] is "Top 5 Customer".

    This will give you a bar chart of the top 5 customers by sales.