The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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?
Solved! Go to Solution.
Thank you very much for fast reply.
I tried your solution. But my full function is like this
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
@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])
Thank you very much for fast reply.
I tried your solution. But my full function is like this
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
5 |
User | Count |
---|---|
25 | |
13 | |
12 | |
8 | |
8 |