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
Anonymous
Not applicable

SUMX with more than one filters and IF

Olá, tenho a Matriz abaixo com as seguintes métricas

 

TesteCad =
var DataInicial = MIN('Date'[Date])
var DataFinal = MAX('Date'[Date])
var _Lote = VALUES(LotDailyCadence[LotNumber])
Return
DIVIDE(
SUMX(FILTER(All(LotDailyCadence),LotDailyCadence[Date]>= DataInicial && LotDailyCadence[Date]<= DataFinal && LotDailyCadence[LotNumber] IN _Lote),LotDailyCadence[TotalProgrammableCadence]),1000)
 
TesteTotal =
var DataInicial = MIN('Date'[Date])
var DataFinal = MAX('Date'[Date])
var _Lote = VALUES(LotDailyCadence[LotNumber])
Return
DIVIDE(SUMX(FILTER(all(LotDailyCadence),LotDailyCadence[Date]= DataFinal && LotDailyCadence[LotNumber] IN _Lote),LotDailyCadence[Lots.TotalQuantity]),1000)
 
TesteCad4 =
var DataInicial = MIN('Date'[Date])
var DataFinal = MAX('Date'[Date])
var _Lote = values(LotDailyCadence[LotNumber])
var _Check =
IF(DIVIDE(SUMX(FILTER(LotDailyCadence,LotDailyCadence[Date]>= DataInicial && LotDailyCadence[Date]<= DataFinal && LotDailyCadence[LotNumber] IN _Lote),LotDailyCadence[TotalProgrammableCadence]),1000)>
DIVIDE(SUMX(FILTER(LotDailyCadence,LotDailyCadence[Date]= DataFinal && LotDailyCadence[LotNumber] IN _Lote),LotDailyCadence[Lots.TotalQuantity]),1000),
DIVIDE(SUMX(FILTER(LotDailyCadence,LotDailyCadence[Date]= DataFinal && LotDailyCadence[LotNumber] IN _Lote),LotDailyCadence[Lots.TotalQuantity]),1000),
DIVIDE(SUMX(FILTER(LotDailyCadence,LotDailyCadence[Date]>= DataInicial && LotDailyCadence[Date]<= DataFinal && LotDailyCadence[LotNumber] IN _Lote),LotDailyCadence[TotalProgrammableCadence]),1000))
return
_Check
 
Quando coloco a métrica para verificar if(TesteCad>TesteTotal, TesteTotal, TesteCad) a somatória final não bate.
Alguem poderia me ajudar??

 

ThiagoOrtiz_0-1651231351012.png

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

The first 2 measures are working fine, right? So for TesteCad4, you can try the measure below. (As there is no sample data to test, not sure if it works, just try it.)

create the measure, and put it into table visual,

testTesteCad4 =
IF (
    HASONEFILTER ( LotDailyCadence[LotNumber] ),
    [TesteCad4],
    SUMX (
        FILTER (
            LotDailyCadence,
            LotDailyCadence[Date] >= DataInicial
                && LotDailyCadence[Date] <= DataFinal
                && LotDailyCadence[LotNumber] IN _Lote
        ),
        [TesteCad4]
    )
)

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

this worked, thanks a lot for the help

v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

The first 2 measures are working fine, right? So for TesteCad4, you can try the measure below. (As there is no sample data to test, not sure if it works, just try it.)

create the measure, and put it into table visual,

testTesteCad4 =
IF (
    HASONEFILTER ( LotDailyCadence[LotNumber] ),
    [TesteCad4],
    SUMX (
        FILTER (
            LotDailyCadence,
            LotDailyCadence[Date] >= DataInicial
                && LotDailyCadence[Date] <= DataFinal
                && LotDailyCadence[LotNumber] IN _Lote
        ),
        [TesteCad4]
    )
)

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

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