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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
educrocha_agu
New Member

Filtro em outra tabela

 

modelagem do bd.png

 

Pessoal, tenho a modelagem acima.

Preciso fazer a contagem da quantidade de registros em "tb_BaseDados" e tenho a seguinte medida

 

Calculate(
count('TB_Base_Dados'[PK])
, filter('TB_Base_Dados', [DtRelatorio] >= DATEVALUE("01/05/2021"))
)
 
E funciona como esperado, fazendo a contagem dos registros de TB_BASE_DADOS.
 
Agora preciso incluir mais uma restrição tb_Conteudo[Conteudo] = 'SIM'
Calculate(
  count('TB_Base_Dados'[PK])
  , filter('TB_Base_Dados', [DtRelatorio] >= DATEVALUE("01/05/2021")
             & 'tb_Conteudo'[Conteudo] >= "SIM"
           )
 )
 

O problema é que ao inserir a segunda restrição, dá erro: "Um único valor para a coluna 'Conteudo' na tabela 'tb_Conteudo' não pode ser determinado.

 

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @educrocha_agu,

 

Not sure how you create relationships for the tables in your model. But you may try this Measure.

RecordsSIM =
VAR res =
    CALCULATE (
        COUNT ( 'tb_BaseDados'[pk] ),
        FILTER (
            'tb_BaseDados',
            'tb_BaseDados'[dtRelatorio] >= DATEVALUE ( "01/05/2021" )
                && MAX ( 'tb_Conteudo'[Conteudo] ) = "SIM"
        )
    )
RETURN
    res

 

RecordsSIM with proper total =
VAR midT =
    ADDCOLUMNS ( VALUES ( tb_BaseDados[pk] ), "val", [RecordsSIM] )
RETURN
    SUMX ( midT, [val] )

 

Then, the result looks like this.

vcazhengmsft_0-1653540890852.png

 

Also, attach the pbix as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know how. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

1 REPLY 1
v-cazheng-msft
Community Support
Community Support

Hi @educrocha_agu,

 

Not sure how you create relationships for the tables in your model. But you may try this Measure.

RecordsSIM =
VAR res =
    CALCULATE (
        COUNT ( 'tb_BaseDados'[pk] ),
        FILTER (
            'tb_BaseDados',
            'tb_BaseDados'[dtRelatorio] >= DATEVALUE ( "01/05/2021" )
                && MAX ( 'tb_Conteudo'[Conteudo] ) = "SIM"
        )
    )
RETURN
    res

 

RecordsSIM with proper total =
VAR midT =
    ADDCOLUMNS ( VALUES ( tb_BaseDados[pk] ), "val", [RecordsSIM] )
RETURN
    SUMX ( midT, [val] )

 

Then, the result looks like this.

vcazhengmsft_0-1653540890852.png

 

Also, attach the pbix as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know how. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.