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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AleMacedo
Helper I
Helper I

Need help with formula

I have 4 tables with relationships:

 

- UA: IdUnit, UnitName, IdUnitDependents and informations about Units

         IdUnitDependents is lilke 1 < 239 < 938 where each number corresponds a hierarchy IdUnit

- Adressess : Units Adressess, City, ZipCode

- Employees: NameofEmployee, UA (Employee IdUnit)

- UnitsExpenses: Expenses with maintenance of buildings

Need to calculate:

- Number of Employees in each UA (Unit), including dependents (need to search number inside IdUnitDependents column) like need to know count of employess with code 239 in IdUnitDependents

- Sum of Expenses with maintenance calculated for Unit including depentens same as Employess - is necessary to Divide Total Expenses per Adress than divide per Employes in this adress and then multiply per Employees of Unit with dependents


 

I have this formula to calculate expenses:
Per Person: 

 

Servico Continuo por Pessoa =
var IntegrantesAtivosCTIC = calculate(count(Integrante[NomeIntegrante]), filter(all(Integrante),Integrante[FlagSituacao]="A"))
var IntegrantesAtivosADM = calculate(count(Integrante[NomeIntegrante]),Integrante[FlagSituacao]="A")
var SContinuos = SUMMARIZE(DespesasTotais,DespesasTotais[DESPESA],DespesasTotais[Período],DespesasTotais[Cidade],DespesasTotais[RefIDEnd],"Valor Total", calculate(sum(DespesasTotais[Valor]),DespesasTotais[GRUPO]="Serviços Contínuos",DespesasTotais[GrupoContínuos] = "REGULAR"))
var SContinuosCTIC = SUMMARIZE(DespesasTotais,DespesasTotais[DESPESA],DespesasTotais[Período],"Valor Total",CALCULATE(sum(DespesasTotais[Valor]),DespesasTotais[GrupoContínuos]="CTIC"))
return
divide(sumx(SContinuos,[Valor Total]),IntegrantesAtivosADM) + Divide(sumx(SContinuosCTIC,[Valor Total]),IntegrantesAtivosCTIC)

 

Per Unit:

Servico Continuo por UA =
var IntegrantesAtivosUnidade = SUMMARIZE(Integrante,Integrante[IdUA],"IntegrantesUA", calculate(count(Integrante[NomeIntegrante]),Integrante[FlagSituacao]="A"))
var SContinuosPessoa = 'Medidas Despesas por UA'[Servico Continuo por Pessoa]
return
SContinuosPessoa*sumx(IntegrantesAtivosUnidade,[IntegrantesUA])


Need to include dependents in these formulas and know if the formulas are ok. To complicated for me.
Thanks in advance.
 
1 ACCEPTED SOLUTION
2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @AleMacedo ,

It's hard to reproduce your problem without a sample, could you please give an example to illustrate your problem?

Best Regards,
Community Support Team _ kalyj

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.