Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
I am having a date filter like shown above where the user can select a year (where all months of the year gets selected) or the user can select a specific month (and all days of the month gets selected) or select a specific day. If the user selects a year, the total sales of the entire year is to calculated. If the user selects a month, need to calculate sales of the month only and if the user selects a day, MTD sales is to be calculated. Any ideas for a DAX function to handle this?
Solved! Go to Solution.
hi, @Anonymous
try below measure and see below image it might help
Measure 2 =
var a = HASONEFILTER('Calendar'[Date].[Day])
return
IF(a,CALCULATE([Quantity],DATESMTD('Calendar'[Date])),[Quantity])
for month selection
for day selection
hi, @Anonymous
try below measure
measure =
if(
isinscope(datetable[day column]),
calculate(
sum(tablename[sales]),
removefilters(),
values(datetable[day column]),
datesmtd(datetable[day column])
),
sum(tablename[sales])
)
Hi @Dangar332,
Thanks for your response. When I tried the measure you provided, its returning an error -
A column specified in the call to function 'DATESMTD' is not of type DATE.
So I tried the Date column (and not day coumn), the else part was working fine but the if part is returning the daywise sales and not MTD.
measure =
if(
isinscope('Date Master'[Day]),
calculate(
[Sales Value],
removefilters(),
values('Date Master'[Day]),
datesmtd('Date Master'[Date])
),
[Sales Value])
My Date Master has columns:
hi, @Anonymous
remove
values('Date Master'[Day])
from code
hi, @Anonymous
try below measure and see below image it might help
Measure 2 =
var a = HASONEFILTER('Calendar'[Date].[Day])
return
IF(a,CALCULATE([Quantity],DATESMTD('Calendar'[Date])),[Quantity])
for month selection
for day selection
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
6 | |
4 | |
3 | |
3 |
User | Count |
---|---|
13 | |
11 | |
8 | |
8 | |
8 |