Forum Discussion
Somar com filtro
Bom dia.
Estou tentando somar valores faturados cujo projeto houve custo de mão-de-obra no período analisado.
Preciso criar uma medida para calcular isto, porém, o valor da medida "Faturado Período" resulta o valor total.
Criei duas tabelas para exemplificar o problema:
Na primeira tabela, eu consigo chegar no resultado que quero, porém, preciso utilizar o filtro "não está em branco" na coluna de soma de mão-de-obra.
Na segunda tabela, eu retirei esse filtro, e o resultado é o mesmo da medida "Faturado Período".
Já tentei aplicar vários filtros na função "calculate", mas eles não resultam no valor da primeira tabela, que é a correta.
Como solucionar?
Hi Anonymous ,
Based on your description, I have created a simple sample:
Please try:
Measure = IF(ISINSCOPE('Table'[ID]),SUM('Table'[Value]),CALCULATE(SUM('Table'[Value]),ALL('Table')))Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
Please try:
Measure = IF(ISINSCOPE('Table'[ID]),SUM('Table (2)'[Value]),SUMX(FILTER('Table (2)',RELATED('Table'[Column1])<>BLANK()),[Value]))Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- v-jianboli-msft
Community Support
Hi Anonymous ,
Based on your description, I have created a simple sample:
Please try:
Measure = IF(ISINSCOPE('Table'[ID]),SUM('Table'[Value]),CALCULATE(SUM('Table'[Value]),ALL('Table')))Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Caro Jianbo Li, muito obrigado pela resposta.
Utilizando seu exemplo, o output final que eu desejo é 190, e não 210.
Ou seja, a função deve reconhecer que não há valores na Column1 para o ID 2, e por isto não deve somar a coluna Value.
PS: Imagine que as colunas "Column1" e "Value" estão em tabelas/banco de dados distintos.
Muito obrigado novamente.
- v-jianboli-msft
Community Support
Hi Anonymous ,
Please try:
Measure = IF(ISINSCOPE('Table'[ID]),SUM('Table (2)'[Value]),SUMX(FILTER('Table (2)',RELATED('Table'[Column1])<>BLANK()),[Value]))Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Thank you, Jianbo Li!
Have a nice year!