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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Akbarov
Helper I
Helper I

DAX equivalent for SUMIFS with current row value as filter

Hello Dear community,

 

I have column of sales,

[Quantity] [Client name] [Date]

 

I need DAX function to sum quantity 

SUM [Quantity] 

IF [Date] < Current row

and Client name = Current row

 

It could be something like this in Excel:

Sumifs(Quantity,[Client name],A10,[Date],"<"&C10,..)

 

Can anybodyhelp me please to solve this problem?

1 ACCEPTED SOLUTION

Thank you very much for fast reply.

I tried your solution. But my full function is like this

RELATED('(Table 1) Month'[Days of Month])*('(Table 3) Census'[Endorsement of Month]+
sumx(filter('(Table 3) Census', [Client] =earlier([Client]) && '(Table 3) Census'[Month] < earlier('(Table 3) Census'[Month]) ), '(Table 3) Census'[Active]))
 
I think result was not correct. May be because your function does not works with my function together?
I don't get any error. But can you tell me if full function is fine?
 

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

Hi @Akbarov 

for a calculated column please use

=
VAR CurrentDate = TableName[Date]
RETURN
    CALCULATE (
        SUM ( TableName[Quantity] ),
        TableName[Date] < CurrentDate,
        ALLEXCEPT ( TableName, TableName[Client name] )
    )

 For measure use

=
CALCULATE (
    SUM ( TableName[Quantity] ),
    TableName[Date] < MAX ( TableName[Date] )
)

Hi @tamerj1, I don't understand how this could work as the date will always be inferior to current date hence your formula seems like it would always give the sum of the entire Quantity column. Could you explain ? 

 

Hi @Nacci11 

CurrentDate is tye Date of the current row under iteration.

 

CALCULATETABLE- ALLEXCEPT will produce a table that represent all the rows of the current  client. This table is filtered for every row in the original table for ClientTable.Date < OriginalTable.Date

amitchandak
Super User
Super User

@Akbarov ,

 

A new column  = sumx(filter(Table, [Client] =earlier([Client])  && [Date] < earlier([Date])   ), [Quantity])

 

or

 

A new Measure = sumx(filter(allselected(Table), [Client] =max([Client]) && [Date] < max([Date]) ), [Quantity])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much for fast reply.

I tried your solution. But my full function is like this

RELATED('(Table 1) Month'[Days of Month])*('(Table 3) Census'[Endorsement of Month]+
sumx(filter('(Table 3) Census', [Client] =earlier([Client]) && '(Table 3) Census'[Month] < earlier('(Table 3) Census'[Month]) ), '(Table 3) Census'[Active]))
 
I think result was not correct. May be because your function does not works with my function together?
I don't get any error. But can you tell me if full function is fine?
 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.