Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.
I want to use DatesBetween in an IF Statement:
=if(DatesBetween(Table[Date], Date(2021,03,09), Date(2021,03,21)),1,0)
This won't work because DatesBetween Returns a table of the dates between the range given.
Is there a work around/way to make this work?
I just want to mark the dates 03/09-03/21/21 in my table with a 1.. all other dates with a 0.
Solved! Go to Solution.
Hi @kressb ,
Try with this code..
Measure =
IF (
AND ( Table[Date] >= DATE ( 2021, 03, 09 ), Table[Date] <= DATE ( 2021, 03, 21 ) ),
1,
0
)
hi @kressb try with below measure
Measure = IF (MAX('Table'[Date])>= DATE ( 2021, 03, 01 )&&MAX(Table[Date]) <= DATE ( 2021, 08, 31 ),1,0)
HI @kressb,
You can also use the aggregate function to extract the current date and use the calendar function to generate the date range and use the 'in' operator to compare with them.
Measure =
VAR currDate =
MAX ( Table[Date] )
VAR dateRange =
CALENDAR ( DATE ( 2021, 03, 09 ), DATE ( 2021, 03, 21 ) )
RETURN
IF ( currDate IN dateRange, 1, 0 )
Regards,
Xiaoxin Sheng
Hi @kressb,
Did these suggestions suitable for your scenario? If that is the case, you can consider kudo or accept it to help others who face a similar scenario.
If they not helps, please share some more detailed information to help us clarify and test your situation.
Regards,
Xiaoxin Sheng
HI @kressb,
You can also use the aggregate function to extract the current date and use the calendar function to generate the date range and use the 'in' operator to compare with them.
Measure =
VAR currDate =
MAX ( Table[Date] )
VAR dateRange =
CALENDAR ( DATE ( 2021, 03, 09 ), DATE ( 2021, 03, 21 ) )
RETURN
IF ( currDate IN dateRange, 1, 0 )
Regards,
Xiaoxin Sheng
hi @kressb try with below measure
Measure = IF (MAX('Table'[Date])>= DATE ( 2021, 03, 01 )&&MAX(Table[Date]) <= DATE ( 2021, 08, 31 ),1,0)
Hi @kressb ,
Try with this code..
Measure =
IF (
AND ( Table[Date] >= DATE ( 2021, 03, 09 ), Table[Date] <= DATE ( 2021, 03, 21 ) ),
1,
0
)
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
72 | |
71 | |
70 | |
42 | |
42 |
User | Count |
---|---|
49 | |
42 | |
29 | |
28 | |
26 |