cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vilmar
Helper II
Helper II

Somar Com Vários Critérios Diferentes Dinamicamente

Olá

Preciso somar a quantidade das vendas que estão na tabela esquerda, porem com criterios diferente para cada supervisor da tabela direita. Como fazer isso dinamicamente no power bi?

Tem que ser dinamico, pois os supervisores podem mudar sua supervisão.

Planilha aqui 

 

Veja na tabela direita onde a formula SOMASES tem criterios diferentes para os supervisores:

Sem título.png

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Vilmar 

Thanks for reaching out to us.

You can try this,

Soma Qtde = 
var _s= MIN(List[Supervisor])
return 
SWITCH(TRUE(),
_s="Ajani"||_s="Pratik",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Regiao]=MIN(List[Regiao]) && 'Table'[Categoria]=MIN(List[Categoria]))),
_s="Uehudah"||_s="Edison",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Tipo]=MIN(List[Tipo]))),
_s="Mihoko",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Categoria]=MIN(List[Categoria]))),
_s="Ruthie",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Meio]=MIN(List[Meio]))))

 

result

vxiaotang_1-1653362280394.png

If you have many supervisors, then you can add a column such like below, then use column=1 or 2 to determine which type of formula to choose

vxiaotang_0-1653362187238.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @Vilmar 

Thanks for reaching out to us.

You can try this,

Soma Qtde = 
var _s= MIN(List[Supervisor])
return 
SWITCH(TRUE(),
_s="Ajani"||_s="Pratik",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Regiao]=MIN(List[Regiao]) && 'Table'[Categoria]=MIN(List[Categoria]))),
_s="Uehudah"||_s="Edison",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Tipo]=MIN(List[Tipo]))),
_s="Mihoko",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Categoria]=MIN(List[Categoria]))),
_s="Ruthie",CALCULATE(SUM('Table'[Qtd]),FILTER(ALL('Table'),'Table'[Meio]=MIN(List[Meio]))))

 

result

vxiaotang_1-1653362280394.png

If you have many supervisors, then you can add a column such like below, then use column=1 or 2 to determine which type of formula to choose

vxiaotang_0-1653362187238.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

@v-xiaotang obrigado por responder.

Seria quase isso que fez, mas tinha que ser algo mais dinâmico, pois terei vários supervisores com combinações diferentes, e criar vários valores constantes a ser correspondido no switch, será muito trabalhoso.

 

Mais uma vez, obrigado!

v-xiaotang
Community Support
Community Support

Hi @Vilmar 

Thanks for your reply. In this scenario you can follow the second method I introduced. Since different combinations have different calculation formulas, these are unavoidable and need to be set manually in the measure.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors