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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ezepbi
Regular Visitor

dax formula for sales in different currencies

Hi, i want to create a formula that calculates the sales amount in ARS$ or in USD based on what I've selected in a filter.
But I'm not very good with calculate yet.

I have a sales table connected with a calendar table and a dolar price table connected 1 to 1 with the calendar table (because i have only one dollar price per day); this tables has 3 columns (fecha, precio_compra, precio_venta)

so i was working with this formula

Total_Ventas_Seleccionado =
VAR total_ventas_pesos = SUM(ventas_detalle[Venta])

RETURN
IF(
    SELECTEDVALUE('Seleccion Moneda'[Moneda]) = "Dólares",
    DIVIDE(
        total_ventas_pesos,
        RELATED(cotizacion_dolar_blue[precio_venta])
    ),
    total_ventas_pesos
)

But it's not working, the related line is in red dots and it says the parameter is of the wrong type.
I suppose i could create a relationship directly between the price dollar table and the sales table but i rather use the link with calendar since i have multiples tables with sales and buys that have the price in ARS so I would rather create a good formula.

4 REPLIES 4
suparnababu8
Super User
Super User

Hi @ezepbi 

 

Try with this  

 

Total_Ventas_Seleccionado = 
SWITCH(
        SELECTEDVALUE('Seleccion Moneda'[Moneda]),
        "Dólares", SUMX(ventas_detalle,ventas_detalle[Venta] * RELATED(cotizacion_dolar_blue[precio_venta]),
        "ARS$",  SUM(ventas_detalle[Venta])
        )

 

 

Let me know if it works.

You did it you genius!
well almost, here's what i did

Total_Ventas_Seleccionado =
var ventas_pesos = sum(ventas_detalle[venta])
return
SWITCH(
        SELECTEDVALUE('Seleccion Moneda'[Moneda]),
        "Pesos",  ventas_pesos,
        "Dólares", SUMX(ventas_detalle,ventas_detalle[Venta] / RELATED(cotizacion_dolar_blue[precio_venta])
        ))

i had to divide the sales with the dollar price because the "cotizacion_dolar_blue" table has the price in pesos of 1 USD for every single day
Anonymous
Not applicable

Hi @ezepbi ,

Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!

 

 

Best Regards

Yilong Zhou

Ritaf1983
Super User
Super User

Hi @ezepbi 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.