cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Hydrarian
Helper I
Helper I

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
Community Champion
Community Champion

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])
)

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors