Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello,
I need to do a something like "IF" with dates, for example:
Status = If( date between "2022-10-15" and "2022-10-18", "1",
If( date between "2022-10-19" and "2022-10-22", "2",
If( date between "2022-10-23" and "2022-10-26", "3", "null")))
and returns the results:
Date | Status |
15/10/2022 | 1 |
16/10/2022 | 1 |
17/10/2022 | 1 |
18/10/2022 | 1 |
19/10/2022 | 2 |
20/10/2022 | 2 |
21/10/2022 | 2 |
22/10/2022 | 2 |
23/10/2022 | 3 |
24/10/2022 | 3 |
25/10/2022 | 3 |
26/10/2022 | 3 |
Someone can help me?
Thanks a lot!
Solved! Go to Solution.
Status = If( date >= DATEVALUE("2022-10-15") && date <= DATEVALUE("2022-10-18"), "1",
...
HI @Anonymous
Please try
Status =
SWITCH (
TRUE (),
'Table'[Date] >= DATE ( 2022, 10, 15 )
&& 'Table'[Date] >= DATE ( 2022, 10, 18 ), 1,
'Table'[Date] >= DATE ( 2022, 10, 19 )
&& 'Table'[Date] >= DATE ( 2022, 10, 22 ), 2,
'Table'[Date] >= DATE ( 2022, 10, 23 )
&& 'Table'[Date] >= DATE ( 2022, 10, 26 ), 3
)
Hi @vinicius_ramos ,
I have personally tried this and it worked out.
You can achieve the above by creating a dax calculated column =
Status_column =
IF( 'Date'[Date]>="2022-10-15" && 'Date'[Date]<="2022-10-18"), "1",
IF( 'Date'[Date]>="2022-10-19" && 'Date'[Date]<= "2022-10-19"), "2",
IF('Date'[Date]>= "2022-10-23" && 'Date'[Date]<= "2022-10-26"), "3","null"
)))
this will solve your issue.
Regards,
Nikhil Chenna
Please apprecitate with Kudos, and accept this post as a solution if it works.
Hi @Anonymous ,
I have personally tried this and it worked out.
You can achieve the above by creating a dax calculated column =
Status_column =
IF( 'Date'[Date]>="2022-10-15" && 'Date'[Date]<="2022-10-18"), "1",
IF( 'Date'[Date]>="2022-10-19" && 'Date'[Date]<= "2022-10-19"), "2",
IF('Date'[Date]>= "2022-10-23" && 'Date'[Date]<= "2022-10-26"), "3","null"
)))
this will solve your issue.
Regards,
Nikhil Chenna
Please apprecitate with Kudos, and accept this post as a solution if it works.
This won't work for a calculated column and is a time intelligence function to get a table of dates which are between start and end date.
Status = If( date >= DATEVALUE("2022-10-15") && date <= DATEVALUE("2022-10-18"), "1",
...
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
24 | |
21 | |
18 | |
14 | |
11 |
User | Count |
---|---|
43 | |
35 | |
25 | |
24 | |
22 |