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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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