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
Syndicate_Admin
Administrator
Administrator

Y ayuda para la condición

Hola a todos
Necesito sumar todo el inventario de un artículo durante todo el período por fecha. Hay casos en los que la fecha y la hora son las mismas pero ocurren una tras otra. Aquí está mi fórmula:

accumulated Stock = 
calculate(
sumX('Goods logistics','Goods logistics'[Stock]),
FILTER(All('Goods logistics'),
And('Goods logistics'[ArtID]=EARLIER('Goods logistics'[ArtID]),
'Goods logistics'[Date]<=EARLIER('Goods logistics'[Date])
)))

¿Cómo puedo agregar, si la fecha es la misma que la fecha, también se debe preferir la identificación más pequeña?

ArtIDDate_TimeIdentificaciónAcciónStock acumulado
12301.01.2020 02:20:102203

3

12302.01.2020 04:10:10221-11 <- Debe ser 2
12302.01.2020 04:10:10222-11 <- Debe ser 2
12306.01.2020 01:13:2122523

Gracias por su ayuda.

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

@azaterol Primero asegúrese de que la columna ID debe estar en orden ascendente

A continuación, cree la columna calculada como se indica a continuación

Stock acumulado = 
calcular(
suma('Logística de mercancías'[Stock]),
FILTRO(Todo('Logística de mercancías'),
(«Logística de mercancías»[ArtID]=ANTERIOR(«Logística de mercancías»[ArtID]) &&
«Logística de mercancías»[ID] <= ANTERIOR(«Logística de mercancías»[ID])

)))

@ddpl la fecha es priotity.

Cambié la muestra. Si hay dos o más fechas iguales, el ID está en orden ascendente. Tengo que usar Date_Time en mi fórmula.

ArtID Date_Time Identificación Acción Stock acumulado
123 01.01.2020 02:20:10 229 3

3

123 02.01.2020 04:10:10 221 -1 1 <- Debe ser 2
123 02.01.2020 04:10:10 222 -1 1 <-es correcto
123 06.01.2020 01:13:21 220 2 3

@azaterol Luego, otra opción es agregar índice desde power query y luego

Stock acumulado = 
calcular(
suma('Logística de mercancías'[Stock]),
FILTRO(Todo('Logística de mercancías'),
(«Logística de mercancías»[ArtID]=ANTERIOR(«Logística de mercancías»[ArtID]) &&
'Logística de mercancías'[ÍNDICE] <= ANTERIOR('Logística de mercancías'[ÍNDICE])

)))

@ddpl funciona muy bien. Gracias.

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.

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