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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Measure that converts the values to selected currency

I have a measure that converts the values to selected currency

Отгрузка расчетного года без рейсов = 
var currency_main = SELECTEDVALUE('Контрагенты'[Currency_to_convert])
return 
 SUMX(
    '_заказы_поставщику_товары_без_рейса',
    var kurs_val_o = COALESCE(
                        maxx(
                            FILTER('_курсы валют', 
                                '_курсы валют'[period] = '_заказы_поставщику_товары_без_рейса'[period] && '_курсы валют'[Валюта] = RELATED('ЗП_список'[Валюта])), 
                            '_курсы валют'[Курс]
                        ),
                        1
                    )
    var kurs_val_r = COALESCE(
                        maxx(
                            FILTER('_курсы валют', 
                                '_курсы валют'[period] = '_заказы_поставщику_товары_без_рейса'[period] && '_курсы валют'[Валюта] = currency_main),
                            '_курсы валют'[Курс]
                        ),
                        1
                    )
     return
     '_заказы_поставщику_товары_без_рейса'[quantity]*'_заказы_поставщику_товары_без_рейса'[Цена]*if(RELATED('ЗП_список'[Валюта]) = currency_main, 1,  kurs_val_o/kurs_val_r)
 )

But the problem is when in the table with orders  there are dates with a future period it doesnt convert.

I need to convert the values on the last date of table with currencies . For example , if in table with orders [period]> currency[period], then we calculate on the last date exists in table with currencies.

image_2021-07-02_11-00-11.pngimage_2021-07-02_11-01-20.pngimage_2021-07-02_14-18-25.png

 

@selimovd 

 

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

You can create a measure instead of period, then use it in formula.

Like this:

measure =
VAR a =
    CALCULATE ( MAX ( table2[period] ), ALL ( table2 ) )
RETURN
    IF ( SELECTEDVALUE ( table[period] ) > a, a, SELECTEDVALUE ( table[period] ) )

 

Best Regards

Janey Guo

 

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

View solution in original post

1 REPLY 1
v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

You can create a measure instead of period, then use it in formula.

Like this:

measure =
VAR a =
    CALCULATE ( MAX ( table2[period] ), ALL ( table2 ) )
RETURN
    IF ( SELECTEDVALUE ( table[period] ) > a, a, SELECTEDVALUE ( table[period] ) )

 

Best Regards

Janey Guo

 

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.