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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Filtro de fecha no funciona

Hola, tengo un problema para crear una medida sobre un informe. El informe es una tabla larga en la que represento algunos valores de almacén día a día (consulte la captura de pantalla).

mag.PNG

Estoy tratando de insertar en una medida un filtro de fecha en el que digo (para cada fila del informe):

F - Inventario[Hora de fecha creada] <- (la fecha de campo en el informe, que se toma de un campo de la tabla dimensional D - Fecha[Fecha]).

Lo intenté de esta manera:

NUEVO En Acq Vib Spe - CALCULATE
(
SUMX('F - Inventario','F - Inventario'[Cantidad]*'F - Inventario'[Coste unitario]),
'F - Inventario'[Tipo de transacción]-"Ordine fornitore",
'D - Almacén'[ID de almacén]-"B0",
'D - Elemento'[Tipo]-"Elemento",
'D - Item'[Unified Special]'"Special",
'F - Inventario'[Fecha de inventario]"1900-01-01" ? 'F - Inventario'[Fecha de inventario]>'D - Fecha'[Fecha],
'F - Inventory'[Status ID] EN "StatusReceipt-3", "StatusReceipt-4", "StatusReceipt-5",
'F - Inventario'[Hora de fecha creada]<'D - Fecha'[Fecha]
)
Pero no está funcionando. ¿Cuál es la sintaxis correcta para incluir en la fórmula?
4 REPLIES 4
AntrikshSharma
Super User
Super User

En primer lugar, debe comprender que está utilizando 2 columnas en una operación booleana.

'F - Inventario'[Hora de fecha creada] en 'F - Inventario'[Hora de fecha creada]<'D - Fecha'[Fecha] se expande a

FILTER ( ALL ( 'F - Inventory'[Created Date Time] ), SomeCondition )

Ahora usted está tratando de obtener fechas que están en otra tabla, eso no está permitido porque FILTER & ALL contruct sólo tiene una columna. y lo mismo es cierto para:

'F - Inventory'[Inventory date]="1900-01-01" || 'F - Inventory'[Inventory date]>='D - Date'[Date],

¿Está tratando de calcular un total rodante? si es así, podría usar:

NEW In Acq Vib Spe =
VAR LastAvailableDate = MAX ( 'D - Date'[Date] )
VAR Result =
    CALCULATE (
        SUMX ( 'F - Inventory', 'F - Inventory'[Quantity] * 'F - Inventory'[Unit Cost] ),
        'F - Inventory'[Transaction type] = "Ordine fornitore",
        'D - Warehouse'[Warehouse ID] = "B0",
        'D - Item'[Type] = "Item",
        'D - Item'[SpecialUnificato] = "Speciale",
        'F - Inventory'[Inventory date] = "1900-01-01"
            || 'F - Inventory'[Inventory date] >= LastAvailableDate,
        'F - Inventory'[Status ID]
            IN { "StatusReceipt-3", "StatusReceipt-4", "StatusReceipt-5" },
        FILTER ( ALL ( 'D - Date'[Date] ), 'D - Date'[Date] <= LastAvailableDate )
    )
RETURN
    Result
amitchandak
Super User
Super User

@Hydrarian , Probar como

NEW In Acq Vib Spe = CALCULATE
(
SUMX('F - Inventory','F - Inventory'[Quantity]*'F - Inventory'[Unit Cost]),
,
'D - Warehouse'[Warehouse ID]="B0",
'D - Item'[Type]="Item",
'D - Item'[SpecialUnificato]="Speciale",
Filter('F - Inventory','F - Inventory'[Transaction type]="Ordine fornitore" && ('F - Inventory'[Inventory date]="1900-01-01" || 'F - Inventory'[Inventory date]>='D - Date'[Date]) && 'F - Inventory'[Status ID] IN { "StatusReceipt-3", "StatusReceipt-4", "StatusReceipt-5"}  
&& 'F - Inventory'[Created Date Time]<='D - Date'[Date])
)
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hola, he probado su solución, pero el problema es que no puedo insertar 'D - Fecha'[Fecha]. Si empiezo a escribir me sugiere sólo medidas, mientras que 'D - Fecha'[Fecha] es un campo.

tex628
Community Champion
Community Champion

Parece que está comparando el tipo de fecha con el tipo de cadena. En lugar de usar "1900-01-01", utilice DATE(1900,1,1).

Br
J


Connect on LinkedIn

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors