Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Currently trying to make a running sum of Number1 & Number2 for last 6 months. Something weird is happening at the end, and the logic does not follow the intended calculations.
I used following formula:
Number1_L6M_sum =
CALCULATE (
SUM ( Table1[Number1] ),
filter(all(Table1[Date]), Table1[Date] < min(Table1[Date]) && DATEADD(Table1[Date], 6, MONTH) >= min(table1[Date]))
)
But as you can numbers start to not add up as they approach current date. (Green on left should match green on right and red ditto)
Why is this happening - And what is a potential solution?
Solved! Go to Solution.
Hi @ChristianRHouen ,
I have created a sample for your reference, Please create a measure as below to work on it.
Measure =
VAR pre6 =
EDATE ( MAX ( 'Table 1'[date] ), -6 )
VAR cure =
MAX ( 'Table 1'[date] )
RETURN
CALCULATE (
SUM ( 'Table 1'[Number1] ),
FILTER ( ALL ( 'Table 1' ), 'Table 1'[date] >= pre6 && 'Table 1'[date] <= cure )
)
For more details, please check the pbix as attached.
Hi @ChristianRHouen ,
I have created a sample for your reference, Please create a measure as below to work on it.
Measure =
VAR pre6 =
EDATE ( MAX ( 'Table 1'[date] ), -6 )
VAR cure =
MAX ( 'Table 1'[date] )
RETURN
CALCULATE (
SUM ( 'Table 1'[Number1] ),
FILTER ( ALL ( 'Table 1' ), 'Table 1'[date] >= pre6 && 'Table 1'[date] <= cure )
)
For more details, please check the pbix as attached.
I stand corrected - it's actually quite flexible. The only reason I had issues was that the code should be
'Table 1'[date] <= cure )
Instead of
'Table 1'[date] < cure )
in order to include the last day of the month.
Would you correct your answer, so I can mark it as correct? 🙂
Hi @ChristianRHouen ,
I have updated my previous post:)
Thanks, Frank!
Unfortunately, this solution doesn't seem to scale well, as the underlying data model actually has many rows for each month, and Number1 is actually a Number1 = sum(underlying_number1).
This means that for the sum, I can easily view it in different date buckets, be they year, month, week.
Your solution is definitely more correct than mine, but even if I change the date in your file to years it becomes non-sensical.
Do you have a different solution maybe?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |