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
courartinfo
New Member

calculate with more than one filter, one of them being period

I have a table that has several medical appointments, in these appointments it is reported which patient id, disease, and the date of appointment, I need a measure where I can get the different number of patients who have a certain disease that the care was performed between a certain period.

the measure i created is not right, but i will forward it here to try to understand the idea

Diabeticos Jan20 a Jan21 =

CALCULATE(
DISTINCTCOUNT(atendimento_individual_problemas[co_fat_cidadao_pec]),
FILTER(
atendimento_individual_problemas,
atendimento_individual_problemas[Condições] = "diabetes" &&
atendimento_individual_problemas[Periodo concatenado] DATE >=(2020,01,01) &&
atendimento_individual_problemas[Periodo concatenado] DATE <=(2021,01,01)
),
)
1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @courartinfo ,

Change your dax as below:

Diabeticos Jan20 a Jan21 =
CALCULATE (
    DISTINCTCOUNT ( atendimento_individual_problemas[co_fat_cidadao_pec] ),
    FILTER (
        atendimento_individual_problemas,
        atendimento_individual_problemas[Condições] = "diabetes"
            && atendimento_individual_problemas[Periodo concatenado] >= DATE ( 2020, 01, 01 )
            && atendimento_individual_problemas[Periodo concatenado] <= DATE ( 2021, 01, 01 )
    )
)

You could use the below to check your dax :

https://www.daxformatter.com/ 

 

If question still not solved ,could you pls share your pbix file? Remember to remove confidential data.

 

Best Regards

Lucien

View solution in original post

6 REPLIES 6
v-luwang-msft
Community Support
Community Support

Hi @courartinfo ,

Change your dax as below:

Diabeticos Jan20 a Jan21 =
CALCULATE (
    DISTINCTCOUNT ( atendimento_individual_problemas[co_fat_cidadao_pec] ),
    FILTER (
        atendimento_individual_problemas,
        atendimento_individual_problemas[Condições] = "diabetes"
            && atendimento_individual_problemas[Periodo concatenado] >= DATE ( 2020, 01, 01 )
            && atendimento_individual_problemas[Periodo concatenado] <= DATE ( 2021, 01, 01 )
    )
)

You could use the below to check your dax :

https://www.daxformatter.com/ 

 

If question still not solved ,could you pls share your pbix file? Remember to remove confidential data.

 

Best Regards

Lucien

viviank
Resolver I
Resolver I

You need to turn the numbers (2021,01,01) into a Date format. You can use the Date function to do this. You have Date in your formula - but it's in the wrong spot! You want:

 

atendimento_individual_problemas[Periodo concatenado] >=DATE (2020,01,01) &&
atendimento_individual_problemas[Periodo concatenado] <= DATE (2021,01,01)

 

This gives you some more info on how to use the DATE function in DAX. https://dax.guide/date/


I made the change and the syntax error was fixed, but now another one has appeared...
The '3' argument in the CALCULATE function is required.

I think you have an extra comma at the end.

),
)
 
Remove the last comma - then I hope it works!
HotChilli
Super User
Super User

"measure i created is not right" - Are you getting a syntax error on this or something else?

the power bi flips error in DATE syntax,

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