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! Request now
Buddies ,I want to design a filter that could choose
I make a DAX function
thisDate = IF(WEEKNUM([_DATE]) = WEEKNUM(NOW()),"THIS WEEK", IF(MONTH([_DATE]) = MONTH(NOW()),"THIS MONTH"), IF(YEAR([_DATE] = YEAR(NOW()),"THIS YEAR")))
It work in my column.However, I can't choose "THIS MONTH" include "THIS WEEK".Therefore,I modified the code.
thisDate = IF(WEEKNUM([_DATE]) = WEEKNUM(NOW()),1, IF(MONTH([_DATE]) = MONTH(NOW()),2), IF(YEAR([_DATE] = YEAR(NOW()),3)))
I selected number of three that smaller one need to be selected.Is possible?
btw,If the way come true,the filter will show the 1 ,2 and 3.Can It be modified(i.e.:"this week")?
Hi @RachC,
You can use below formula to check the date range:
Measure:
CheckDate =
var checkYear=YEAR(MAX('Table'[Date]))=YEAR(NOW())
var checkMonth=MONTH(MAX('Table'[Date]))=MONTH(NOW())
var checkWeek=WEEKNUM(MAX('Table'[Date]),1)=WEEKNUM(NOW(),1)
return
IF(checkYear,if(checkWeek,"This Week",if(checkMonth,"This Month","This Year")),"Different Year")
In addition, you can also take a look at following formula which check date based on slicer:
Measures:
Selected = if(HASONEVALUE('Table'[Date]),VALUES('Table'[Date]),BLANK())
CheckDate(Slicer) =
var checkYear=YEAR([Selected])=YEAR(NOW())
var checkMonth=MONTH([Selected])=MONTH(NOW())
var checkWeek=WEEKNUM([Selected],1)=WEEKNUM(NOW(),1)
return
IF(checkYear,if(checkWeek,"This Week",if(checkMonth,"This Month","This Year")),"Different Year")
Regards,
Xiaoxin Sheng
um..it can't resolve my problem.
I thought I explain accurately,the filter need latest 7 day,14 day.
If you set the label in column like this week or this latest14day that you can't contain the other inforamation unless you choose both.But it's not my goal.
I found the M code but I didn't implement with this blog.If it works well I will share in this post!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 97 | |
| 73 | |
| 50 | |
| 46 | |
| 44 |