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
Hi guys, I want to calculate a cumulative value with selected date range, and the slicer may switch M to W(week) or D(day),
is there to be a good way to fullfill that? Thank you
Solved! Go to Solution.
Hi @Anonymous ,
I created some data:
Here are the steps you can follow:
1. Use Enter data to create a table.
2. Create a calendar table.
Date =
CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))
3. Create measure.
Flag_day =
var _mindate=MINX(ALLSELECTED('Table'),'Table'[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),'Table'[Date])
return
IF(
MAX('Date'[Date])>=_mindate&&MAX('Date'[Date])<=_maxdate,1,0)Flag_week =
var _mindate=MINX(ALLSELECTED('Table'),'Table'[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),'Table'[Date])
return
IF(
MAX('Date'[Week])>=WEEKNUM(_mindate,1)&&MAX('Date'[Week])<=WEEKNUM(_maxdate,1),1,0)Flag_month =
var _mindate=MINX(ALLSELECTED('Table'),'Table'[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),'Table'[Date])
return
IF(
MAX('Date'[Month])>=MONTH(_mindate)&&
MAX('Date'[Month])<=MONTH(_maxdate),1,0)Flag =
var _select=SELECTEDVALUE('Table2'[Select])
return
SWITCH(
TRUE(),
_select="Month",[Flag_month],
_select="Week",[Flag_week],
_select="Day",[Flag_day])amount_measure =
SUMX(FILTER(ALL('Table'),'Table'[Date]=MAX('Date'[Date])),[Amount])calculate cumulative value =
SUMX(FILTER(ALL('Date'),'Date'[Date]<=MAX('Date'[Date])),[amount_measure])
4. Place [Flag]in Filters, set is=1, apply filter.
5. Result:
Select "Month", "Week", "Day" according to the slicer, and display the corresponding measure
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @Anonymous ,
I created some data:
Here are the steps you can follow:
1. Use Enter data to create a table.
2. Create a calendar table.
Date =
CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))
3. Create measure.
Flag_day =
var _mindate=MINX(ALLSELECTED('Table'),'Table'[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),'Table'[Date])
return
IF(
MAX('Date'[Date])>=_mindate&&MAX('Date'[Date])<=_maxdate,1,0)Flag_week =
var _mindate=MINX(ALLSELECTED('Table'),'Table'[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),'Table'[Date])
return
IF(
MAX('Date'[Week])>=WEEKNUM(_mindate,1)&&MAX('Date'[Week])<=WEEKNUM(_maxdate,1),1,0)Flag_month =
var _mindate=MINX(ALLSELECTED('Table'),'Table'[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),'Table'[Date])
return
IF(
MAX('Date'[Month])>=MONTH(_mindate)&&
MAX('Date'[Month])<=MONTH(_maxdate),1,0)Flag =
var _select=SELECTEDVALUE('Table2'[Select])
return
SWITCH(
TRUE(),
_select="Month",[Flag_month],
_select="Week",[Flag_week],
_select="Day",[Flag_day])amount_measure =
SUMX(FILTER(ALL('Table'),'Table'[Date]=MAX('Date'[Date])),[Amount])calculate cumulative value =
SUMX(FILTER(ALL('Date'),'Date'[Date]<=MAX('Date'[Date])),[amount_measure])
4. Place [Flag]in Filters, set is=1, apply filter.
5. Result:
Select "Month", "Week", "Day" according to the slicer, and display the corresponding measure
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi,
Share the link from where i can download your PBI file.
sorry, I found no ways to send you a file or link😐
Google Drive/One Drive and a host of other service providers.
edited
That link takes me to an error page.
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.