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.
I have this data with Group and Values. I want to sum "Values" on a rolling window of 4 rows sorted by "Date". I want this calculation seperately for each "Group".
Date | Group | Value | Result |
2/1/2022 | 1 | 0 | |
2/2/2022 | 1 | 1 | |
2/3/2022 | 1 | 0 | |
2/4/2022 | 1 | 1 | 2 (0+1+0+1) |
2/5/2022 | 1 | 1 | 3 (1+0+1+1) |
2/1/2022 | 2 | 0 | |
2/2/2022 | 2 | 1 | |
2/3/2022 | 2 | 0 | |
2/4/2022 | 2 | 1 | 2 |
2/5/2022 | 2 | 1 | 3 |
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
Value measure: =
SUM( Data[Value] )
Four rows rolling sum: =
VAR fourlatestdays =
TOPN (
4,
FILTER (
ALL ( Data ),
Data[Group] = MAX ( Data[Group] )
&& Data[Date] <= MAX ( Data[Date] )
),
Data[Date], DESC
)
VAR result =
CALCULATE (
[Value measure:],
FILTER ( ALL ( Data ), Data[Group] = MAX ( Data[Group] ) ),
fourlatestdays
)
RETURN
IF (
HASONEVALUE ( Data[Date] ),
IF ( COUNTROWS ( fourlatestdays ) < 4, BLANK (), result )
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
Please check the below picture and the attached pbix file.
Value measure: =
SUM( Data[Value] )
Four rows rolling sum: =
VAR fourlatestdays =
TOPN (
4,
FILTER (
ALL ( Data ),
Data[Group] = MAX ( Data[Group] )
&& Data[Date] <= MAX ( Data[Date] )
),
Data[Date], DESC
)
VAR result =
CALCULATE (
[Value measure:],
FILTER ( ALL ( Data ), Data[Group] = MAX ( Data[Group] ) ),
fourlatestdays
)
RETURN
IF (
HASONEVALUE ( Data[Date] ),
IF ( COUNTROWS ( fourlatestdays ) < 4, BLANK (), result )
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Thanks for helping me out!
Now i am trying to use this rolling sum in a card visual,Can you also help me with my query below?
I am using a dashboard to track latest data from "Rolling_sum" column. This "Rolling_sum" column is Whole number data type. Whenever i am trying to use it as a card it shows aggregation. I just want to show the latest information without any aggregation just like any text column.
I have tried creating a new measure which duplicates the "Rolling_sum" column using "FIXED" to convert it into text. But, using it in a card dosent allow me to choose "First" or "Last" values.
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 |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |