Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
The situation is to find a rolling sum of the last 12 months for a date column but also need to use another column to get the final range of valid dates to pass in a variable. (rolling sum for overlapping date range from two data columns in a table)
Apologies for cross-posting as it seems that on this forum I can get quick help. https://chandoo.org/forum/threads/dateinperiod-with-two-column-to-pass-in-dax-for-rolling-sum.50610/...
The first code works well for calculating rolling SUM for the last 12 months.
LTFail-Communication = VAR NumOfMonths = 12
VAR LTFailCutoff = LOOKUPVALUE(
FailureData_ICF_Trend[ProductMaster.CutOffWarrenty],
FailureData_ICF_Trend[ProductMaster.prod221],"COMMUNICATION"
)
VAR LastCurrentDate =EOMONTH(
MAX (FailureData_ICF_Trend[repairmonth]),0)
VAR Period =
DATESINPERIOD ( 'Calender'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Result =
CALCULATE (
SUMX(
VALUES ('Calender'[Date]), FailureData_ICF_Trend[FailQty_Trend]),Period,
FailureData_ICF_Trend[ProductMaster.prod221]= "COMMUNICATION"
)
VAR FirstDateInPeriod = MINX ( Period, 'Calender'[Date] )
VAR LastDateWithSales = EOMONTH(MAX ( FailureData_ICF_Trend[repairmonth] ),0)
RETURN
IF ( FirstDateInPeriod <= LastDateWithSales, Result )
Now another filter of a different date column is also required so i tried to modify this to use another dateinperiod to get the final valid data range. I am not able to figure out how to use the new VAR Period 1 in the Result variable along with the existing period. Basically, it's like putting sumifs in Excel for Period Variable
LTFail-ToDeleteOriginal = VAR NumOfMonths = 12
VAR LTFailCutoff = LOOKUPVALUE(
FailureData_ICF_Trend[ProductMaster.Life Warrenty.years],
FailureData_ICF_Trend[ProductMaster.prod221],"COMMUNICATION"
)
VAR LastCurrentDate =EOMONTH(
MAX (FailureData_ICF_Trend[repairmonth]),0)
VAR LastCurrentDateInvoice =EOMONTH(
MAX (ShipmentData_ICF_T[invoicemonth]),0)
VAR Period =
DATESINPERIOD ( 'Calender'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Period1 = DATESINPERIOD ( 'CalenderRepairCutoff'[Date], LastCurrentDateInvoice, - LTFailCutoff, YEAR )
VAR Result =
CALCULATE (
SUMX(
VALUES ('Calender'[Date]), FailureData_ICF_Trend[FailQty_Trend]),Period,
FailureData_ICF_Trend[ProductMaster.prod221]= "COMMUNICATION",
)
VAR FirstDateInPeriod = MINX ( Period, 'Calender'[Date] )
VAR LastDateWithSales = EOMONTH(MAX ( FailureData_ICF_Trend[repairmonth] ),0)
RETURN
IF ( FirstDateInPeriod <= LastDateWithSales, Result )
Thanks in advance
@kuldeepjain Try this method: Better Rolling Average - Microsoft Power BI Community Just use SUMX instead of AVERAGEX
Thanks Greg, the issue is to get the comman range (overlapping dates) like sumif on two different coloum and then pass these dates for rolling sum
Or you can understand like and conditions in dateinperiod function.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.