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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Total en ejecución basado en la categoría

Con la siguiente tabla 'Datos', Me gustaría escribir una medida que calcula el total de ejecución basado en "Producto".

Tabla de entrada: 'Datos'

ProductoTipoCosto
AMaterial200
APersonal150
AMáquina80
BMaterial300
BPersonal140
BMáquina120
CMaterial240
CPersonal200
CMáquina10

Salida ideal:

ProductoCostoCost Running Total
B560560
C4501010
A4301440

Mi solución actual es usar la siguiente fórmula DAX para crear una tabla calculada,'Datos por producto'; conectar las dos tablas,'Datos'y 'Datos por producto' con una tabla de relaciones, 'Producto' que contiene sólo "A", "B", "C" ,y finalmente utilizar la siguiente medida, " Cost RunningTotal" para calcular el costo total de ejecución basado en la columna [Coste] en orden descendente.

Data by Product = 
SUMMARIZE(
    'Data',
    Data[Product],
    "Cost", SUM(Data[Cost])
)

Cost Running Total = 
    CALCULATE(
        SUM(Data[Cost]),
        FILTER(
            ALLSELECTED('Product'[Product]),
            Data[Cost] >= MIN('Data by Product'[Cost])
        )
    )

¿Alguna forma menos engorrosa de realizar el mismo cálculo?

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@CKWong, pruebe esto:

1. Cree una tabla ProductMaster. Ordene la columna Producto por la columna Index (controla la ordenación en el objeto visual de la tabla).

DataInsights_0-1600280855916.png

2. Une ProductMaster a la tabla de datos.

DataInsights_1-1600280893819.png

3. Crear medidas.

Total Cost = SUM ( ProductCost[Cost] )

Running Total = 
VAR vSelProd =
    SELECTEDVALUE ( ProductMaster[Index] )
VAR vResult =
    CALCULATE (
        [Total Cost],
        ProductMaster[Index] <= vSelProd,
        ALL ( ProductMaster[Product] )
    )
RETURN
    vResult

4. Cree un objeto visual de tabla, utilizando ProductMaster[Product] y las medidas.

5. Resultado:

DataInsights_2-1600280916750.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

FrankAT
Community Champion
Community Champion

Hola @CKWong

qué pasa con la siguiente solución:

16-09-_2020_22-32-55.png

Sum of Cost = SUM(Data[Cost])

Running Total = 
CALCULATE(
    [Sum of Cost],
    FILTER(
        ALL(Data),
        MIN(Data[Product]) <= Data[Product]
    )
)

Con saludos amables desde la ciudad donde la leyenda del 'Pied Piper de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

View solution in original post

2 REPLIES 2
FrankAT
Community Champion
Community Champion

Hola @CKWong

qué pasa con la siguiente solución:

16-09-_2020_22-32-55.png

Sum of Cost = SUM(Data[Cost])

Running Total = 
CALCULATE(
    [Sum of Cost],
    FILTER(
        ALL(Data),
        MIN(Data[Product]) <= Data[Product]
    )
)

Con saludos amables desde la ciudad donde la leyenda del 'Pied Piper de Hamelin' está en casa
FrankAT (Orgulloso de ser un Datanaut)

DataInsights
Super User
Super User

@CKWong, pruebe esto:

1. Cree una tabla ProductMaster. Ordene la columna Producto por la columna Index (controla la ordenación en el objeto visual de la tabla).

DataInsights_0-1600280855916.png

2. Une ProductMaster a la tabla de datos.

DataInsights_1-1600280893819.png

3. Crear medidas.

Total Cost = SUM ( ProductCost[Cost] )

Running Total = 
VAR vSelProd =
    SELECTEDVALUE ( ProductMaster[Index] )
VAR vResult =
    CALCULATE (
        [Total Cost],
        ProductMaster[Index] <= vSelProd,
        ALL ( ProductMaster[Product] )
    )
RETURN
    vResult

4. Cree un objeto visual de tabla, utilizando ProductMaster[Product] y las medidas.

5. Resultado:

DataInsights_2-1600280916750.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

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

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors