- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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 new column caculated the most 5 customers having sales .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Ranya
I'm not sure if you found a solution.
If not, here is a calculated column for your Customer table:
Top 5 Sales CC =
VAR _Cust = [CustomerID]
VAR _Table1 =
SUMMARIZE(
ALL( 'Orders' ),
Orders[CustomerID],
"__Sales",
SUM( Orders[Sales] )
)
VAR _Table2 =
ADDCOLUMNS(
_Table1,
"__Rank",
RANK(
DENSE,
_Table1,
ORDERBY( [__Sales], DESC )
)
)
VAR _Table3 =
ADDCOLUMNS(
_Table2,
"__Top5Sales",
IF( [__Rank] < 6, [__Sales], 0 )
)
VAR _Result =
MAXX(
FILTER(
_Table3,
[CustomerID] = _Cust
),
[__Top5Sales]
)
RETURN
_Result
If you have any questions, let me know.
Calculate top customer column.pbix
Proud to be a Super User!
daxformatter.com makes life EASIER!

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
05-15-2024 11:29 AM | |||
07-01-2024 10:29 AM | |||
10-11-2024 12:20 PM | |||
07-17-2024 10:59 AM | |||
06-05-2024 02:40 AM |