- 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
Select Values with max Values in the subtotal
Hi all,
I hava this issue that I'am not able to solve with combinations of formulas lookupvalue, related or something similar.
I have a master data table with the customer name and the department.
The revenue are in another table, linked to the firs one.
I have to add some columns in the master data file, with the information of the most productive sales agent, main region, etc. based on the revenue (data) and department (assigned).
thank for help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you Adamk Kong.
It is better to do it in Power Query.
The solution I am sharing is for Calculated column(Not Measure)
Since you did not share any file, datamodel, I am considering these tables as not related.
Please see if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you Adamk Kong.
It is better to do it in Power Query.
The solution I am sharing is for Calculated column(Not Measure)
Since you did not share any file, datamodel, I am considering these tables as not related.
Please see if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Anonymous ,
You can try below calculated column to create 'sales agent' and 'region' column in Master Data.
MostProductiveSalesAgent =
VAR filter_table =
FILTER (
'Revenue',
'Revenue'[customer] = MAX ( 'Master Data'[customer] )
&& 'Revenue'[department] = MAX ( 'Master Data'[department] )
)
RETURN
CALCULATE (
VALUES ( 'Revenue'[sales agent] ),
filter_table,
TOPN ( 1, filter_table, [revenue], DESC )
)
MainRegion =
VAR filter_table =
FILTER (
'Revenue',
'Revenue'[customer] = MAX ( 'Master Data'[customer] )
&& 'Revenue'[department] = MAX ( 'Master Data'[department] )
)
RETURN
CALCULATE (
VALUES ( 'Revenue'[region] ),
filter_table,
TOPN ( 1, filter_table, [revenue], DESC )
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This solution doesn't works, but, most importatnt, does not consider that there is a "double relation".
MostProductiveAgent is not only linked to the Customer but also to the department.
As visible in the example, the MostProductiveAgent is "C" but i have to not consider him because the department is not in scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To achieve this in Power BI or Excel, you can use a combination of functions like RELATED, CALCULATE, MAXX, and EARLIER. Here's a general guide on how you could approach this:
Let's assume you have a table named MasterData with columns CustomerName and Department, and another table named RevenueData with columns CustomerName, Revenue, SalesAgent, and Region.
Create relationships:
- Make sure there is a relationship between the CustomerName column in the MasterData table and the CustomerName column in the RevenueData table.
Create calculated columns in the MasterData table:
- Most productive sales agent:
MostProductiveAgent =
CALCULATE(
TOPN(1, RevenueData, RevenueData[Revenue], DESC),
FILTER(RevenueData, RevenueData[CustomerName] = MasterData[CustomerName])
) [SalesAgent]
Main region:
MainRegion =
CALCULATE(
TOPN(1, RevenueData, RevenueData[Revenue], DESC),
FILTER(RevenueData, RevenueData[CustomerName] = MasterData[CustomerName])
) [Region]
Adjust the column names based on your actual column names.
Now, you should have two new columns in your MasterData table (MostProductiveAgent and MainRegion) that display the most productive sales agent and main region based on revenue and department.
Please note that this approach assumes there is a one-to-many relationship between the MasterData and RevenueData tables. If there are different relationships or if you need to consider additional conditions, you may need to modify the formulas accordingly. Additionally, make sure to handle potential scenarios where there might be ties for the highest revenue.
Remember to adapt the column names and table names based on your actual data model.

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
09-01-2024 11:51 PM | |||
09-10-2024 02:00 PM | |||
07-01-2024 04:51 AM | |||
04-27-2024 07:06 PM | |||
09-27-2024 04:38 AM |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
9 |