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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply

Filter with 2 conditions, without messing other filters

Bom dia,

 

Eu gostava de fazer uma fórmula em dax onde gostaria que houvesse um dos filtros que fosse baseado em duas tabelas distintas como mostra a fórmula:

 

 

 

 

Measure = 
CALCULATE(
    SUM('Caracterização Efetivo'[Número Empregados]),
    FILTER(
        'Grupo Empregado',
        'Grupo Empregado'[Código Grupo Empregado] IN {"B", "C", "L"}
    ),
    FILTER( 
        'Grupo Empregado',
        'Grupo Empregado'[Código Subgrupo Empregado] IN {"B3", "B4", "B6", "B7", "C3", "C4", "C6", "C7", "L3", "B9", "C9", "L8", "L4"} 
    ),
    FILTER('Grupo Empregado',
            'Grupo Empregado'[Código Subgrupo Empregado] IN {"B5", "C5", "L5"} 
            && 
            CALCULATE(
                SUM('Caracterização Efetivo'[Número Empregados]),
                FILTER( 'Tipo Contrato',
                'Tipo Contrato'[Código Tipo Contrato] = "73")
            )),

    FILTER(
        'Unidade Organizacional',
        'Unidade Organizacional'[Código Autoridade Controlo Efetivos] = "5"
    ),
    FILTER(
        'Estado Ocupação',
        'Estado Ocupação'[Código Estado Ocupação] IN {"1", "3"}
    ),
    FILTER(
        'Caracterização Efetivo',
        'Caracterização Efetivo'[ID_MES] = MAX('Caracterização Efetivo'[ID_MES])
    )
)

 

 


Ela não dá erro mas não retorna nenhum tipo de dados.

 

I want to do a filter that only filters if he matches 2 conditions ( 

'Tipo Contrato'[Código Tipo Contrato] = "73"

 and 

 'Grupo Empregado'[Código Subgrupo Empregado] IN {"B5", "C5", "L5"}

 but they are from different tables.

 

Poderiam ajudar?
6 REPLIES 6
Anonymous
Not applicable

Thanks for the reply from Sahir_Maharaj  please allow me to provide another insight:

Hi,@josegracaaxians 

Could you please let us know if Sahir_Maharaj 's response resolved your issue? If it did, kindly accept it as the solution.

vlinyulumsft_0-1733997590504.png

Since we don't have the complete test data, we can't accurately determine if Sahir_Maharaj 's response has resolved your issue. If you need our assistance, please provide the relevant data structure information, especially the table relationships, so we can test our solution effectively.

 

We recommend uploading it to GitHub and sharing the link with us.When uploading a file, please be careful to delete sensitive information.

 

For questions about uploading data, you can try the following links:

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Solved: How to upload PBI in Community - Microsoft Fabric Community


Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
 

Best Regards,

Leroy Lu

Sahir_Maharaj
Super User
Super User

Hello @josegracaaxians,

 

Can you please try this approach:

Measure =
CALCULATE(
    SUM('Caracterização Efetivo'[Número Empregados]),
    
    FILTER(
        'Grupo Empregado',
        'Grupo Empregado'[Código Grupo Empregado] IN {"B", "C", "L"}
    ),
    
    FILTER(
        'Grupo Empregado',
        'Grupo Empregado'[Código Subgrupo Empregado] IN {"B3", "B4", "B6", "B7", "C3", "C4", "C6", "C7", "L3", "B9", "C9", "L8", "L4"}
    ),

    FILTER(
        'Grupo Empregado',
        'Grupo Empregado'[Código Subgrupo Empregado] IN {"B5", "C5", "L5"} &&
        CALCULATE(
            COUNTROWS('Tipo Contrato'),
            FILTER('Tipo Contrato', 'Tipo Contrato'[Código Tipo Contrato] = "73")
        ) > 0
    ),

    FILTER(
        'Unidade Organizacional',
        'Unidade Organizacional'[Código Autoridade Controlo Efetivos] = "5"
    ),
    
    FILTER(
        'Estado Ocupação',
        'Estado Ocupação'[Código Estado Ocupação] IN {"1", "3"}
    ),
    
    FILTER(
        'Caracterização Efetivo',
        'Caracterização Efetivo'[ID_MES] = MAX('Caracterização Efetivo'[ID_MES])
    )
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

hey, it doesnt fit cause I cant use it to some visuals:

josegracaaxians_0-1734630657242.png

Here, for example it would only show the 192!

Anonymous
Not applicable

Hi @josegracaaxians 

To better assist you in resolving the issue, we need you to provide relevant information about your data structure, particularly the table relationships. This will help us effectively test and optimise our solution.

 

We recommend that you upload this information to GitHub and share the link with us. When uploading the files, please ensure that any sensitive information is removed to maintain data security.

 

For questions about uploading data, you can try the following links:

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Solved: How to upload PBI in Community - Microsoft Fabric Community

 

Thank you for your cooperation!

 

Best Regards,

Leroy Lu

This 3 tables are related with only 2 relationships:

Caracterização Efetivo -> (Many -to-one)Grupo Empregado with  ID_GRUPO_EMPREGADO

Caracterização Efetivo -> (Many -to-one)Tipo de Contrato with ID_TIPO_CONTRATO

josegracaaxians_0-1735209639713.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors