Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
In my report I have a separate start and end filter for selecting time period.
I have to calculate sellout amount to EUR, by using a sellout column in sales table and the exchange rate from the exchange rate table.
The tricky part is, that if Aug 22 is selected, they want everything to be calculated with Aug 22 ex rate. If Jul 22 is selected as end period, they want everything to be calculated on that exchange rate.
First I had an ex rate table like this:
and it was connected with many to many relationship to the sales table by the country code column.
Sales amount was calculated with the help of a lookup function. The disadvantage of the Lookup function is the performance. RELATED function would be much faster, but for that I would need a one to many relationship.
Now, what I am trying to do, is that I modified the exchange rate table, pivoted it, so that I have the ex rates in different columns and I can now establish the one to many relationship to the sales table.
I can use now the RELATED function, but as each month is in a different column, I would have to add each and every column in the code, in the switch function. (The code always have to use the exchange rate of the selected end period)
Is it possible to reference the column name with a measure, instead of adding 50-60 lines of code, each month one by one? It should always use the column name that is identical with the selected end period.
Thank you!
Sellout Amount EUR test =
VAR ex_ratedate = SELECTEDVALUE(Endperiod[yearmonth number])
RETURN
SUMX(
sales, sales[sellout]*
SWITCH(
TRUE(),
ex_ratedate=202101, RELATED(exchange_rate[202101]),
ex_ratedate=202102, RELATED(exchange_rate[202102]),
RELATED(exchange_rate[202206])))
See if you can adapt the solution below. It uses a bridge table to solve the many-to-many relationship. In your model, CountryCode will be the bridge table. This approach allows you to avoid pivoting the exchange rate table.
Proud to be a Super User!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
73 | |
71 | |
38 | |
29 | |
28 |
User | Count |
---|---|
99 | |
88 | |
62 | |
42 | |
39 |