Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hola Equipo,
Tengo dos tablas, Ventas y Moneda. Vea a continuación:
Me gustaría rellenar Sales.Exchange Rate GBP y Sales.Exchange Rate USD con los tipos de cambio de la tabla de divisas (los valores anteriores son mis resultados esperados)
La lógica que necesito usar se ve algo como esto (para GBP):
select earliest exchange rate from Currency where Sales.Currency = Currency.Source and Currency.Target = 'GBP' and Sales.Date > Currency.Date
¿Cómo puedo lograr esto?
Solved! Go to Solution.
https://www.dropbox.com/s/o04lz90nbzttotv/reporting%20model.pbix?dl=0
Tipo de cambio GBP CC=
VAR sourcecurrency = Solicitudes[Moneda]
VAR targetcurrency = "GBP"
VAR currentdate = Solicitudes[Fecha solicitada]
VAR maxcurrencydate =
CALCULAR (
MAX ( 'Moneda'[fecha] ),
FILTRO (
«Moneda»,
'Moneda'[fecha] <= fecha actual
&& 'Moneda'[sourcecurrency] = sourcecurrency
&& 'Moneda'[targetcurrency] = targetcurrency
)
)
devolución
CALCULAR (
CALCULATE ( SUM ( 'Moneda'[tipo de cambio] ) ),
FILTRO (
«Moneda»,
'Moneda'[fecha] = maxcurrencydate
&& 'Moneda'[sourcecurrency] = sourcecurrency
&& 'Moneda'[targetcurrency] = targetcurrency
)
)
Gracias @Jihwan_Kim ,
Agradezco el tiempo que pasó haciendo esto, voy a tratar de que funcione
Veo que ha creado una tabla SourceCurrency, ¿es este un paso necesario además de mi tabla de moneda actual? Mis monedas de origen tienen más que solo AUD, así que idealmente preferiría no tener que crear esto
J
Tienes razón.
Si no tiene otras monedas, no es obligatoriamente necesario.
Hay @Jihwan_Kim
He intentado implementar su solución pero no está funcionando, he adjuntado un enlace a un modelo PowerBI. Como puede ver, estoy tratando de agregar una nueva columna a mi tabla 'Solicitudes' pero no está devolviendo resultados
https://www.dropbox.com/s/o04lz90nbzttotv/reporting%20model.pbix?dl=0
Tipo de cambio GBP CC=
VAR sourcecurrency = Solicitudes[Moneda]
VAR targetcurrency = "GBP"
VAR currentdate = Solicitudes[Fecha solicitada]
VAR maxcurrencydate =
CALCULAR (
MAX ( 'Moneda'[fecha] ),
FILTRO (
«Moneda»,
'Moneda'[fecha] <= fecha actual
&& 'Moneda'[sourcecurrency] = sourcecurrency
&& 'Moneda'[targetcurrency] = targetcurrency
)
)
devolución
CALCULAR (
CALCULATE ( SUM ( 'Moneda'[tipo de cambio] ) ),
FILTRO (
«Moneda»,
'Moneda'[fecha] = maxcurrencydate
&& 'Moneda'[sourcecurrency] = sourcecurrency
&& 'Moneda'[targetcurrency] = targetcurrency
)
)
Hay @Jihwan_Kim ,
Gracias, funciona.
Tuve que agregar una función DATEVALUE a mi variable currentdate ya que se quejaba de comparar fecha y cadenas.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |