Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi, There
i like to seeking help for below funciton :
We have a talbe to record case data , i like to summarize those data group by Case class; Grade on previous 12 hour interval , and calculate evey hours.
Data Sample:
Result Sample
Solved! Go to Solution.
This single DAX formula will create the entire summary table you need.
Result Table =
// This formula generates a summary for every hour, calculating the sum of weight
// for each Case class and Grade over the preceding 12-hour window.
// Step 1: Create a table of every unique combination of Case class and Grade.
VAR GroupingKeys =
SUMMARIZE ( 'Source Data', 'Source Data'[Case class], 'Source Data'[Grade] )
// Step 2: Create a table containing every single hour between the first and last transaction.
VAR MinDateTime =
MIN ( 'Source Data'[Red Data] )
VAR MaxDateTime =
MAX ( 'Source Data'[Red Data] )
VAR HourlyTimePoints =
GENERATESERIES (
DATE ( YEAR ( MinDateTime ), MONTH ( MinDateTime ), DAY ( MinDateTime ) )
+ TIME ( HOUR ( MinDateTime ), 0, 0 ),
MaxDateTime,
TIME ( 1, 0, 0 )
)
VAR HourlyBins =
SELECTCOLUMNS ( HourlyTimePoints, "End date", [Value] )
// Step 3: Create the final table structure by combining every hourly point with every group.
VAR FinalTableShell =
CROSSJOIN ( HourlyBins, GroupingKeys )
// Step 4: Calculate the rolling sum for each row and format the output.
RETURN
SELECTCOLUMNS (
FILTER (
ADDCOLUMNS (
FinalTableShell,
"Weight",
VAR EndWindow = [End date]
VAR StartWindow = EndWindow - TIME ( 12, 0, 0 )
RETURN
CALCULATE (
SUM ( 'Source Data'[Weight (Net)] ),
KEEPFILTERS ( 'Source Data'[Case class] = EARLIER ( [Case class] ) ),
KEEPFILTERS ( 'Source Data'[Grade] = EARLIER ( [Grade] ) ),
'Source Data'[Red Data] > StartWindow
&& 'Source Data'[Red Data] <= EndWindow
)
),
[Weight] > 0
),
"Date", FORMAT ( [End date], "M/d/yyyy h:mm" ),
"Start Date", [End date] - TIME ( 12, 0, 0 ),
"End date", [End date],
"Case class", [Case class],
"Grade", [Grade],
"Weight", "Sum(Weight)" -- This is just a text label as in your example
)
If this explanation and solution resolve your issue, please like and accept the solution.
This single DAX formula will create the entire summary table you need.
Result Table =
// This formula generates a summary for every hour, calculating the sum of weight
// for each Case class and Grade over the preceding 12-hour window.
// Step 1: Create a table of every unique combination of Case class and Grade.
VAR GroupingKeys =
SUMMARIZE ( 'Source Data', 'Source Data'[Case class], 'Source Data'[Grade] )
// Step 2: Create a table containing every single hour between the first and last transaction.
VAR MinDateTime =
MIN ( 'Source Data'[Red Data] )
VAR MaxDateTime =
MAX ( 'Source Data'[Red Data] )
VAR HourlyTimePoints =
GENERATESERIES (
DATE ( YEAR ( MinDateTime ), MONTH ( MinDateTime ), DAY ( MinDateTime ) )
+ TIME ( HOUR ( MinDateTime ), 0, 0 ),
MaxDateTime,
TIME ( 1, 0, 0 )
)
VAR HourlyBins =
SELECTCOLUMNS ( HourlyTimePoints, "End date", [Value] )
// Step 3: Create the final table structure by combining every hourly point with every group.
VAR FinalTableShell =
CROSSJOIN ( HourlyBins, GroupingKeys )
// Step 4: Calculate the rolling sum for each row and format the output.
RETURN
SELECTCOLUMNS (
FILTER (
ADDCOLUMNS (
FinalTableShell,
"Weight",
VAR EndWindow = [End date]
VAR StartWindow = EndWindow - TIME ( 12, 0, 0 )
RETURN
CALCULATE (
SUM ( 'Source Data'[Weight (Net)] ),
KEEPFILTERS ( 'Source Data'[Case class] = EARLIER ( [Case class] ) ),
KEEPFILTERS ( 'Source Data'[Grade] = EARLIER ( [Grade] ) ),
'Source Data'[Red Data] > StartWindow
&& 'Source Data'[Red Data] <= EndWindow
)
),
[Weight] > 0
),
"Date", FORMAT ( [End date], "M/d/yyyy h:mm" ),
"Start Date", [End date] - TIME ( 12, 0, 0 ),
"End date", [End date],
"Case class", [Case class],
"Grade", [Grade],
"Weight", "Sum(Weight)" -- This is just a text label as in your example
)
If this explanation and solution resolve your issue, please like and accept the solution.
Thanks, its working perfect.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.