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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Syndicate_Admin
Administrator
Administrator

Gran Total No Calcular correctamente

Hola

Estoy creando un presupuesto de P&L usando una matriz de desglose. Para Gastos, tengo reglas diferentes para cada "Categoría de Sub Expense", por ejemplo, para excluir ciertos centros de coste y áreas de tipo de actividad. Para ello, he utilizado SELECTVALUE para saber qué regla "Categoría de gastos sub" se aplicará.

Creo una medida para calcular el 'Año Presupuestario 1'. Los totales son correctos en un nivel de fila, pero calcula el gasto total incorrectamente, ya que está ignorando las reglas de "Categoría de sub expenseo" y tampoco calcula en un nivel total general. ¿Cómo puedo hacer que esto funcione y es posible en Power BI? Quiero que el gasto total en cada nivel, el gasto total (es decir , -7 + 49) y finalmente los ingresos - Gastos (-7+49+60) en un nivel total general.

1er Gato2o Gato3er gatoPresupuesto Año 1
GastoSueldo de excepciónPersonal de tiempo completo-7
Total-7
SalarioPersonal de tiempo completo-49
Total-49
Total <no calcular>
IngresosIngresos internosCuotas estudiantiles60
Total60
Total 60
Total <no calcular>

Presupuesto Año 1 ?

var firstCategory = SELECTEDVALUE('P&L Structure'[1stCat]) 
var secondCategory = SELECTEDVALUE('P&L Structure'[2ndCat]) 
var revenue = SUMX(Budget, Budget[Amount])
var expense = 
SWITCH(TRUE(),
secondCategory = "Salary", - CALCULATE(SUMX(Budget, Budget[Amount]), FILTER(Budget, NOT (Budget[CostCentre] = 9900 && Budget[ActivityArea] = "AA1"))), 
secondCategory = "Exception Salary",  - CALCULATE(SUMX(Budget, Budget[Amount]), FILTER(Budget, NOT (Budget[CostCentre] = 9600 && Budget[ActivityArea] = "AA1"))))
var result =
SWITCH(TRUE(),
firstCategory = "Revenue", revenue,
firstCategory = "Expense", expense)
RETURN
result

Adjunto es mi archivo pbix ejemplo.

https://drive.google.com/file/d/1nWPTQJglcJX7oHoBAJuJBNIjGs79AKed/view?usp=sharing

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

@suz20 , Probar como

var firstCategory = SELECTEDVALUE('P&L Structure'[1stCat]) 
var secondCategory = SELECTEDVALUE('P&L Structure'[2ndCat]) 
var revenue = SUMX(Budget, Budget[Amount])
var expense = 
SWITCH(TRUE(),
secondCategory = "Salary", - CALCULATE(SUMX(Budget, Budget[Amount]), FILTER(Budget, NOT (Budget[CostCentre] = 9900 && Budget[ActivityArea] = "AA1"))), 
secondCategory = "Exception Salary",  - CALCULATE(SUMX(Budget, Budget[Amount]), FILTER(Budget, NOT (Budget[CostCentre] = 9600 && Budget[ActivityArea] = "AA1"))))
var result =
sumx(summarize('P&L Structure','P&L Structure'[1stCat],'P&L Structure'[2ndCat],'P&L Structure'[3rdCat],"_1", SWITCH(TRUE(),
firstCategory = "Revenue", revenue,
firstCategory = "Expense", expense)),[_1])
RETURN
result

View solution in original post

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

@suz20 , Probar como

var firstCategory = SELECTEDVALUE('P&L Structure'[1stCat]) 
var secondCategory = SELECTEDVALUE('P&L Structure'[2ndCat]) 
var revenue = SUMX(Budget, Budget[Amount])
var expense = 
SWITCH(TRUE(),
secondCategory = "Salary", - CALCULATE(SUMX(Budget, Budget[Amount]), FILTER(Budget, NOT (Budget[CostCentre] = 9900 && Budget[ActivityArea] = "AA1"))), 
secondCategory = "Exception Salary",  - CALCULATE(SUMX(Budget, Budget[Amount]), FILTER(Budget, NOT (Budget[CostCentre] = 9600 && Budget[ActivityArea] = "AA1"))))
var result =
sumx(summarize('P&L Structure','P&L Structure'[1stCat],'P&L Structure'[2ndCat],'P&L Structure'[3rdCat],"_1", SWITCH(TRUE(),
firstCategory = "Revenue", revenue,
firstCategory = "Expense", expense)),[_1])
RETURN
result

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors
Top Kudoed Authors