Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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.
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.
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.
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
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.
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:
Create calculated columns in the MasterData table:
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
14 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
21 | |
13 | |
11 | |
10 | |
10 |