Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello everyone,
I am working with a historic currency table which has the following columns:
Currency, ExchangeRate, ExchangeRateDate.
I am trying to get a DAX measure which would give me the oldest currency exchange rate for each currency. When I say the oldest, I mean the oldest value that is defined by my date slicer in the report. This date can be modified by the user via the slicer, therefore I cannot use a calculated column or table but I need to do it in a DAX measure.
For example, if my slicer is set between 2018/12/31 and 2019/12/31, I would like to get the exchange rates on the 2018/12/31. Below is the result I would like to obtain (it should be in a measure which will be used in another measure afterwards).
Currency | ExchangeRate | Date |
GBP | 0.66 | 31/12/2018 |
INR | 0.77 | 31/12/2018 |
USD | 0.88 | 31/12/2018 |
To give a more concrete situation, I need to add a column with this value to this table:
I tried using the CALCULATE function, but it requires me to use an aggregation function, which I do not need, and when I use eg. MAX it returns the highest exchange rate accross the different currencies.
The relation model between my dimensions and facts are:
I find it weird that I cannot "simply" do the equivalent of the follow SQL query in DAX
select *
from ExchangeRate as er
join DimCalendar as dc on er.Date = dc.Date
where er.Date = min(dc.Date)
;
I am pretty sure my problem is context related but I can't quite get it.
Any help would be terrific. Please let me know if I did not provide enough information.
Best regards,
Thomas
Hi @Anonymous ,
Please try this:
Measure =
var mindate = MIN(DimCalendar[Date])
return
CALCULATE(MAX(ExchangeRate[ExchangeRate]),FILTER(ExchangeRate,ExchangeRate[Date] = mindate))
It will show maximum value by default. If you want to show total values, please try this:
Measure 2 =
var mindate = MIN(DimCalendar[Date])
return
CALCULATE(SUM(ExchangeRate[ExchangeRate]),FILTER(ExchangeRate,ExchangeRate[Date] = mindate))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |