Improve Power BI measure that takes to long to work

  Kiến thức lập trình

I have this Power BI measure

Delta Movimento =
VAR DefaultDate = DATE(1900, 1, 1)
VAR ConfDate = SELECTEDVALUE(DimPurchaseOrder[ConfirmedShippingDate], DefaultDate)
VAR MovDate = SELECTEDVALUE(FactWmsInventory[MovementDate])
VAR ReqDate = SELECTEDVALUE(DimPurchaseOrder[RequestedShippingDate])

RETURN
SWITCH(
TRUE(),
ConfDate = DefaultDate, DATEDIFF(MovDate, ReqDate, DAY),
DATEDIFF(MovDate, ConfDate, DAY)
)

I use it in a table with 15 field from different tables, I can not modify the data model (as in add calculated columns) so i need to use a measure but this one takes minutes. How can I improve this?

LEAVE A COMMENT