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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
mottamatheus835
Frequent Visitor

Calculation between 2 tables with conditions

OLÁ,

Tenho o seguinte caso:

Tabela vendas:

- Meta Alcançável (é a o quanto da meta já deveria ter sido alcançado -- Meta / Dias úteis * Dias Passados)

- Dias Úteis  (Medida calculada a partir de uma tabela data)

- Dias passados (Medida -- Dias úteis - Dias úteis restantes )

 

Tabela Lojas:

- Número da loja (chave da relação entre as tabelas)

- Abre final de semana (Sim ou Não)

Preciso fazer um cálculo da medida META ALCANÇÁVEL, mas se caso um valor específico de outra tabela esteja sendo selecionado, o cálculo no visual leve em consideração outra condição de dias, isso porque nem todas as lojas abrem somente em dias úteis, mas sim todos os dias.

Por exemplo, tenho um gráfico de barras e no valor da META ALCANÇÁVEL da LOJA X, que não abre final de semana e possui na tabela Lojas o campo ABRE FINAL DE SEMANA como Sim, o ideal seria em vez dos dias úteis o total de dias do mês atual e nos dias passados atuais do relatório. 

META ALCANÇÁVEL = META / TOTAL DE DIAS DO MÊS ATUAL * DIAS PASSADOS ATUAIS 

 

 

Seguem os dados em Link:

https://drive.google.com/drive/folders/1ohkzA_ocKKAbymZNCXtJ2q3nupCjXBo9?usp=sharing 

Exemplo de um resultado esperado:

No caso da Loja 5 uma das que abrem todos os dias, o cálculo seria:

Meta - R$350.000

Dias Úteis - 31 (Nesse caso são os totais de dias do mês de outubro)

Dias Passados - 24 (dia dessa mensagem, mas no cálculo seria uma função Today, provavelmente)

 

META ALCANÇÁVEL = META / TOTAL DE DIAS DO MÊS ATUAL * DIAS PASSADOS ATUAIS 

META ALCANÇÁVEL = 350.000/ 31 * 24

META ALCANÇÁVEL = 270967,74

3 REPLIES 3
Anonymous
Not applicable

Hi @mottamatheus835,

You can add an if statement to your formula with isfiltered function to check if the specific field has been filtered. Then you can parameterized the calculation formula with the different expressions to achieve dynamic switch formulas based on filter effects.

ISFILTERED, ISCROSSFILTERED – DAX Guide - SQLBI

Regards,

Xiaoxin Sheng

Hi @Anonymous . I tested, but for what I want it doesn't work. I need to make the IF function see the specific fields that are been filtered. The entire column will give me a wrong Meta Alcançável.

Anonymous
Not applicable

HI @mottamatheus835,

Can you please share the formula and expected result? They should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.