Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
lukmtb08
Helper III
Helper III

Calculate YTD values with different exchange rates per month

Hi,

 

I would like to calculate the ytd value for the following tables under consideration of the different monthly Exchange rates:

Turnover

Year month keyValue
2022011000
2022022000
  

 

Exchange rates 

Year month keyRate
2022011.1
2022021.2
  

 

Reult shoud be: 
1.1 * 1000 + 1.2 * 2.000

 

Is there a simple DAX solution which solves my problem with a measure? 

Thanks for your support! 

 

BR

3 REPLIES 3
ibarrau
Super User
Super User

Hi lukmtb08. Considering you have a relationship between those tables and assuming the year month is unique column key for exchange rates, you can build something like this:

Sum value new rates =
SUMX(
    Turnover,
    Turnover[Value] * RELATED('Exchange rates'[keyRate])
)

Once you have the sumarization of the rates and values you can calculate YTD

YTD new rates = 
CALCULATE(
    [Sum value new rates]
    , DATESYTD( CalendarTable[Date] )
)

That should make it work. If you have a different model than my assumption please show us more to help you.

I hope that helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Dear ibarrau, thank you very much! It works fine. 

One additional question 🙂 

We do not have date fields as we report just monthly data. Therefore we have Reporting months (1-12). 
Can we calculate the YTD value based on a slicer for the Reporting months.

 

Example.

 

Slicer = Month 10 

-> YTD measure should calculate the values for 1-10

 

Is possibile to add a calculate expression? 

Example: 

Sum value new rates YTD =
Calculate(
SUMX(
Turnover,
Turnover[Value] * RELATED('Exchange rates'[keyRate])
),  Table[Month] <= Selectedvalue Table[Month])
)

 

Thanks you for your support! 🙂

Hi. You still can use YTD if you make changes on your model. Create a calendar table to use YTD. Then add a new column for the table with monthly value. Convert the period format 2022-05 to the first day of the month like 2022-05-01. Once you have that date you can relate it with the calendar like any date to use time intelligence measures.

I hope that make sense.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors