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