March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello there,
I'm trying to create a Power Bi measure to replicate a SUMIF in Excel.
Using the example data below, what I'd like to do, for each row, is sum up Number if Date 1 is <= Date 2 minus variable.
e.g. on the first rown, 5th Jan minus 3 days is 2nd Jan, so "Aggregate -3" is 100.
Then on the 2nd and 3rd rows, 6th Jan minus 4 days is 3rd Jan, so "Aggregate -3" is 500. Aggresate - 4 takes us back to the 2nd Jan, so that columns would have -600.
Any idea how I can do this in a Power Bi method please?
Many thanks
Variable | 3 | 4 | |||
Region | Date 1 | Date 2 | Number | Aggregate (-3) | Aggregate (-4) |
Europe | 2-Jan | 5-Jan | 100 | 100 | 100 |
Europe | 3-Jan | 6-Jan | 200 | 500 | 600 |
Europe | 3-Jan | 6-Jan | 300 | 500 | 600 |
Europe | 4-Jan | 7-Jan | 400 | 3000 | 3700 |
Asia | 4-Jan | 7-Jan | 500 | 3000 | 3700 |
Asia | 4-Jan | 7-Jan | 600 | 3000 | 3700 |
Asia | 4-Jan | 7-Jan | 700 | 3000 | 3700 |
Asia | 4-Jan | 7-Jan | 800 | 3000 | 3700 |
Hi. I don't fully understand what is variable. But let's continue. I think you are looking something like this
VAR variable = ????
RETURN
SUMX ( FILTER ( Table , Table[Date1] <= Table[Date2] - variable ) , Table[Number] )
Hope this helps,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Happy to help!
I should have added, the Variable is driven by a slicer, so the value of the measure needs to change as the slicer changes.
Many thanks
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
26 | |
21 | |
20 | |
14 | |
10 |