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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Problems with multiple filter

Dear Friends,
I am new to PBI and finding problems in getting the solution above,
I really don´t know if there is a problem with the logic or with the function itself, 
I have tried with if() function but Dax compiler keeps saying that I am not allowed to do such filter or if condition.
thanks and best regards !
 
testcalculate =
VAR ano =
FORMAT ( YEAR ( MAX ( FatoOpex[Data] ) ) - 3; "####" )
RETURN

CALCULATE(sum(FatoOpex[valor]);

FILTER( FatoOpex;
FatoOpex[exDiretoria] = "0" &&
FatoOpex[DimCalendario.Ano]=ano)
 
||

FILTER(FatoOpex;
FatoOpex[exDiretoria] = "1" &&
FatoOpex[DimNatureza.idNatureza]="7" &&
FatoOpex[DimCalendario.Ano]=ano))
1 ACCEPTED SOLUTION
Iamnvt
Continued Contributor
Continued Contributor

hi,

 

the syntax:

CALCULATE ( <Expression> [, <Filter> [, <Filter> [, … ] ] ] )

treat Filter1, Filter2 with the AND operations.

 

to use the OR operations, you need to use it within the same filter. 

testcalculate =
VAR ano =
    FORMAT ( YEAR ( MAX ( FatoOpex[Data] ) ) - 3; "####" )
RETURN
    CALCULATE (
        SUM ( FatoOpex[valor] );
        FILTER(FatoOpex; 
OR ( FatoOpex[exDiretoria] = "0" && FatoOpex[DimCalendario.Ano] = ano; FatoOpex[exDiretoria] = "1" && FatoOpex[DimNatureza.idNatureza] = "7" && FatoOpex[DimCalendario.Ano] = ano ) )

 

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Give this a try

testcalculate =
VAR ano =
    FORMAT ( YEAR ( MAX ( FatoOpex[Data] ) ) - 3; "####" )
RETURN
    CALCULATE (
        SUM ( FatoOpex[valor] );
        OR (
            FatoOpex[exDiretoria] = "0"
                && FatoOpex[DimCalendario.Ano] = ano;
            FatoOpex[exDiretoria] = "1"
                && FatoOpex[DimNatureza.idNatureza] = "7"
                && FatoOpex[DimCalendario.Ano] = ano
        )
    )
Anonymous
Not applicable

thank you for your try, but have this :

"The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression."

 

 

Iamnvt
Continued Contributor
Continued Contributor

hi,

 

the syntax:

CALCULATE ( <Expression> [, <Filter> [, <Filter> [, … ] ] ] )

treat Filter1, Filter2 with the AND operations.

 

to use the OR operations, you need to use it within the same filter. 

testcalculate =
VAR ano =
    FORMAT ( YEAR ( MAX ( FatoOpex[Data] ) ) - 3; "####" )
RETURN
    CALCULATE (
        SUM ( FatoOpex[valor] );
        FILTER(FatoOpex; 
OR ( FatoOpex[exDiretoria] = "0" && FatoOpex[DimCalendario.Ano] = ano; FatoOpex[exDiretoria] = "1" && FatoOpex[DimNatureza.idNatureza] = "7" && FatoOpex[DimCalendario.Ano] = ano ) )

 

Anonymous
Not applicable

thank you ! it worked fine!


Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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