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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
swaroopkumarmg
Helper II
Helper II

SUMIFS in DAX

Hello there,

I'm trying to replicate a function- SUMIFS from excel to Power BI. 

 

I have the following Tables and i need to sum the Hours (Total Hours) based on the criterias.

 

Table 1:

Stage CodeStageBandTotal Hours
1Suspect25050
1Suspect5000
2In progress2500
2In progress50025
3Won25028
3Won50023

 

Table 2:

CaseHoursStage CodeBand
AAAA201250
BBBB252500
CCCC233500
DDDD301250
EEEEE283250

 

Formula used: =SUMIFS(Table2[Hours],Table2[Band],[Band],Table2[Stage Code],[Stage Code])

 

Please help me figure this out!!

 

Thanks

SMG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

If you want the calculated column to be in Table 1, the tables need to be connected by a relationship. I would recommend you create a unique key for each stage and band combination so you can connect the tables.

Use the following as a calculated column in both tables.

StageBandKey =
CONCATENATE ( Table1[Stage Code], Table1[Band] )

StageBandKey =
CONCATENATE ( Table2[Stage Code], Table2[Band] )

Then connect the tables via the relationship view using the shared key.

You'll then be able to use the previous code in a calculated column in Table 1 to get the hours for each stage - band combination.

View solution in original post

5 REPLIES 5
v-eachen-msft
Community Support
Community Support

Hi @swaroopkumarmg ,

 

You can create the measure “Total Hours” to meet your needs.

Total Hours =
VAR s =
    CALCULATE (
        SUM ( Table2[Hours] ),
        FILTER (
            Table2,
            Table2[Band] = MAX ( Table1[Band] )
                && Table2[Stage Code] = MAX ( Table1[Stage Code] )
        )
    )
RETURN
    IF ( ISBLANK ( s ), 0, s )

Then you can get result you want.4-1.PNG

Best Regards,

Eads

 

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

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

Try the following as a calculated column in Table 2:

Total hours column =
CALCULATE ( SUM ( Table2[Hours] ), Table2[Band], Table2[Stage Code] )

Thanks a ton for your reply and suggestion.

 

I tried this, it did not give any error, but the Hours Column in the Table 1 is with blank values

 

Any suggestion?

 

 

Anonymous
Not applicable

If you want the calculated column to be in Table 1, the tables need to be connected by a relationship. I would recommend you create a unique key for each stage and band combination so you can connect the tables.

Use the following as a calculated column in both tables.

StageBandKey =
CONCATENATE ( Table1[Stage Code], Table1[Band] )

StageBandKey =
CONCATENATE ( Table2[Stage Code], Table2[Band] )

Then connect the tables via the relationship view using the shared key.

You'll then be able to use the previous code in a calculated column in Table 1 to get the hours for each stage - band combination.

That worked like a charm. 

 

thanks a ton!! 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.