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.
Buenas tardes,
Tengo un modelo de datos en el que estoy tratando de calcular, por medio de una columna calculada, los costes asociados a un producto, según el producto, la moneda en la que se realiza la factura y la fecha de la factura.
En el siguiente ejemplo, que adjunto en archivo "pbix" con datos de muestra, disponemos de dos orígenes de datos, los costes de productos en base a moneda y fecha (por las exportaciones de producto y las variaciones de coste) y las facturas de venta (identificando fecha, moneda y producto).
https://drive.google.com/file/d/1heOdC5omBtv_qOCljaHI6-AaMCDDFcBy/view?usp=sharing
Mi objetivo es asociar el coste producto de la fecha anterior más cercana cuando la fecha de la factura no coincida con ninguna fecha de coste.
Por ejemplo:
Hasta ahora he conseguido obtener el coste cuando la fecha de la factura es igual a la fecha de coste, pero no consigo completar con los costes del día anterior más cercano.
Me gustaría conseguir una columna como se muestra en la siguiente imagen "Coste fecha anterior más cercana".
¿Cuál sería la opción y expresión adecuada para calcularlo?
Gracias. Un saludo,
Jacob
Solved! Go to Solution.
Hi @jacob2102,
Please change the 'calculate' function in the variable 'list' to 'calculatetable' to fix the issue:
Measure =
VAR dateStart =
MIN ( Calendar[Date] )
VAR dateEnd =
MAX ( Calendar[Date] )
VAR list =
CALCULATETABLE (
VALUES ( Table[Date] ),
ALLSELECTED ( Table ),
VALUES ( Table[ID] )
)
RETURN
IF (
MINX ( list, [Date] ) = dateStart
&& MAX ( list, [Date] ) = dateEnd,
"Y",
"N"
)
Regards,
Xiaoxin Sheng
Hi @jacob2102,
I'm not so sure about your descriptions, did you mean to filter the records with two conditions? (e.g. filter records that start at xxx, end at xxx)
If that is the case, you can use the current category as a condition to filter the date list, then you can extract the min and max date from that list as conditions to filter records.
Measure =
VAR dateStart =
MIN ( Calendar[Date] )
VAR dateEnd =
MAX ( Calendar[Date] )
VAR list =
CALCULATE (
VALUES ( Table[Date] ),
ALLSELECTED ( Table ),
VALUES ( Table[ID] )
)
RETURN
IF (
MINX ( list, [Date] ) = dateStart
&& MAX ( list, [Date] ) = dateEnd,
"Y",
"N"
)
Regards,
Xiaoxin Sheng
Hi,
Thanks for your answer, but not is possible to create this measure using the return expression using "MINX(list... && MAX(list...))".
Regards,
Jacob
Hi @jacob2102,
Please change the 'calculate' function in the variable 'list' to 'calculatetable' to fix the issue:
Measure =
VAR dateStart =
MIN ( Calendar[Date] )
VAR dateEnd =
MAX ( Calendar[Date] )
VAR list =
CALCULATETABLE (
VALUES ( Table[Date] ),
ALLSELECTED ( Table ),
VALUES ( Table[ID] )
)
RETURN
IF (
MINX ( list, [Date] ) = dateStart
&& MAX ( list, [Date] ) = dateEnd,
"Y",
"N"
)
Regards,
Xiaoxin Sheng
Tienes soluciónes en este hilo:
https://community.powerbi.com/t5/Desktop/Duplicar-filas-con-fechas-diferentes/m-p/2037653#M763738
las has probado?
Si aún así tienes dudas, ponlas que te ayudaremos (pero en el hilo original por favor)
(y por favor, no dupliques preguntas que se dispersan soluciones y concocimientos )
Proud to be a Super User!
Paul on Linkedin.
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 |
---|---|
111 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |