Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have trouble with sum with condition. I do not have specific method needed, either power query or Dax is fine.
If Date1>=Date2 then sum QTY
But I want to compare Date1 each row with every row in column Date2, please see my sample data as below table. The calue I need is column "Need this value"
thank you very much in advance.
Date 1 | Date 2 | Qty | Need this value | How to calculate |
1-Nov | 2-Nov | 2 | 0 | 1-Nov(Date1) is less than 2-Nov (Date2)and less than 4-Nov(Date2 in second row) and less than every Date in column Date2 then shows 0 |
1-Nov | 4-Nov | 1 | 0 | Same with above |
2-Nov | 3-Nov | 3 | 2 | 2-Nov(Date1) is = 2-Nov (Date2)then 2 and less than 4-Nov(Date2 in second row) then 0 and less than the rest Date in column Date2 then final result will be 2 |
3-Nov | 4-Nov | 4 | 5 | 3-Nov(Date1) is more than 2-Nov (Date2)then 2 and less than 4-Nov(Date2 in second row) then 0 and equals to 3-Nov(Date2 in third row) then 3 and less than the rest Date in column Date2 then final result will be 2+3 =5 |
4-Nov | 5-Nov | 2 | 10 | 4-Nov(Date1) is more than 2-Nov (Date2)then 2 and equals to 4-Nov(Date2 in second row) then 1 and more than 3-Nov(Date2 in third row) then 3 and equals to 4-Nov(Date2 in forth row) then 4 and less than the rest Date in column Date2 then final result will be 2+1+3+4=10 |
5-Nov | 6-Nov | 3 | 12 | 5-Nov(Date1) is more than 2-Nov (Date2)then 2 and equals to 4-Nov(Date2 in second row) then 1 and more than 3-Nov(Date2 in third row) then 3 and equals to 4-Nov(Date2 in forth row) then 4 and equals to 5-Nov (Date2 in fifth row) then 2, then final result will be 2+1+3+4+2 = 12 |
Hi @Pinarali
please try
Need this value =
VAR CurrentDate1 = 'Table'[Date1]
RETURN
SUMX ( FILTER ( 'Table', 'Table'[Date2] <= CurrentDate1 ), 'Table'[Qty] ) + 0
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
8 |