Forum Discussion
TREATAS with Event Database
- 8 months ago
Hi DianaDM96,
I hope you are doing well today ☺️❤️
So your issue is that your FX Value 3 measure is using SUMMARIZE over Employee Events which creates a dependency on the current filter context from your date slicer (When no employee events match the selected date the virtual relationship fails)
So How to Solve this issue?
Here is a better approach using TREATAS you can Try:
FX Value 3 = VAR SelectedDate = MAX('Calendar'[Date]) VAR EndOfMonthDate = EOMONTH(SelectedDate, 0) VAR CurrenciesInScope = CALCULATETABLE( VALUES('Employee Events'[Currency]), 'Employee Events'[Effective Start Date] <= SelectedDate, 'Employee Events'[Effective End Date] >= SelectedDate, REMOVEFILTERS('Calendar') ) RETURN CALCULATE( MAX('FX Rates'[Value]), TREATAS( CurrenciesInScope, 'FX Rates'[Currency] ), 'FX Rates'[Date] = EndOfMonthDate, REMOVEFILTERS('Calendar') )And for your Annualized Salary in USD measure:
Annualized Salary (USD) = VAR SelectedDate = MAX('Calendar'[Date]) VAR BaseSalary = [Annualized Salary (LC)] VAR FXRate = [FX Value 3] RETURN DIVIDE(BaseSalary, FXRate, 0)This should give you the expected outcome where selecting any date in the Date slicer will show Annualized Salary (USD) and FX Value for all users who are active at that point in time (not just those with events starting on the selected date)
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. - 8 months ago
Hi DianaDM96,
Your welcome! I am glad I could help reduce your stress that's what we are here for! 😊
The problem is that your measure is calculating at the row level correctly but at the total level, it is not iterating through each employee individually to convert their salary
So You could try this and i hope it work:
Annualized Salary (USD) = VAR SelectedDate = MAX('Calendar'[Date]) VAR ActiveEmployees = CALCULATETABLE( 'Employee Events', 'Employee Events'[Effective Start Date] <= SelectedDate, 'Employee Events'[Effective End Date] >= SelectedDate, REMOVEFILTERS('Calendar') ) RETURN SUMX( ActiveEmployees, VAR EmployeeSalary = 'Employee Events'[Annualized Salary (LC)] VAR EmployeeCurrency = 'Employee Events'[Currency] VAR FXRate = CALCULATE( MAX('FX Rates'[Value]), TREATAS({EmployeeCurrency}, 'FX Rates'[Currency]), 'FX Rates'[Date] = EOMONTH(SelectedDate, 0), REMOVEFILTERS('Calendar') ) RETURN DIVIDE(EmployeeSalary, FXRate, 0) )Tell me if It works ☺️❤️
THIS IS FANTASTIC, THANK YOU SO VERY MUCH!!! You have no idea how much this helps. Not only that, but I added more page slicers and it works. This is such an elegant, comprehensive solution, thank you very much.
- Ahmed-Elfeel8 months agoSuper User
I'm so happy to hear this! Your message truly made my day!☺️❤️