Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hive mind,
I am running into an interesting problem when dealing with many-to-many relationship and table totals. It is killing me to know what I am doing wrong, I've spent hours trying to figure out out. Since so many of you are better at this than me, I thought I'd try here.
I have the following tables: dimEmployees and Revenue Detail time entries
I am calculating their total hours and revenue, separately for each period when they worked for the team (this employee had multiple transfers).
Additionally - there is a revenue entry for 3/31/2019. This should not be included at all because duing this time the employee was not a part of the team.
Below is an example of the results. First using implicit measures, in which case Power BI sums up everything for all three time periods, which is nto what I want. In the last two columns I am using calculated measures. They work for the separate timeframes, but the totals don't add up.
The code for the calculated revenue is as follows:
How can this be done better?
I have attached a pbix with the tables and calculated measures. PBIX
Solved! Go to Solution.
Hi @Evgenia
try this.
Calculated Revenue =
SUMX (
Employees;
SUMX (
FILTER (
RevenueDetail;
(
RevenueDetail[Date] <= CALCULATE ( MAX ( Employees[TransferDate] ) )
&& RevenueDetail[Date] >= CALCULATE ( MAX ( Employees[HireDate] ) )
)
);
RevenueDetail[Revenue]
)
)
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Hi @Evgenia
try this.
Calculated Revenue =
SUMX (
Employees;
SUMX (
FILTER (
RevenueDetail;
(
RevenueDetail[Date] <= CALCULATE ( MAX ( Employees[TransferDate] ) )
&& RevenueDetail[Date] >= CALCULATE ( MAX ( Employees[HireDate] ) )
)
);
RevenueDetail[Revenue]
)
)
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Thank you so much @mwegener !
I had no idea SUMX can be used like this across multiple tables. So much to learn!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |