Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello, I am getting an error in this IF statement. I have tried "IF" and "IIF". Do you happen to see where I am wrong? I am wanting to add a custom column to tag rows that are greater than the current date - 8 days. maybe there is a better way to do this. I do not see how I can filter my [Date] column for the criteria unless I add a helper column as below.
= Table.AddColumn(#"Sorted Rows", "Filter Grtr 8 days", each IIF((NOW()-[Date])<8,"Y","N"))
Solved! Go to Solution.
Hi @Centaur ,
I already updated my code to correct this when I spotted it.
Also, based on your reply to jennratten, I think you will need to add a Date.From function to truncate the datetime value of today:
if Duration.Days(Date.From(DateTime.LocalNow()) - [Date]) < 8 then "Y" else "N"
Pete
Proud to be a Datanaut!
Hi @Centaur ,
The correct IF statement syntax in Power Query is ' if..then..else if..else'.
I think your statement would need to be something like this:
if Duration.Days(DateTime.LocalNow() - [Date]) < 8 then "Y" else "N"
Pete
Proud to be a Datanaut!
Hi Pete,
thank you. I get an error though "2 arguments were passed...."?
Hi @Centaur ,
I already updated my code to correct this when I spotted it.
Also, based on your reply to jennratten, I think you will need to add a Date.From function to truncate the datetime value of today:
if Duration.Days(Date.From(DateTime.LocalNow()) - [Date]) < 8 then "Y" else "N"
Pete
Proud to be a Datanaut!
Here you are (assuming your date field is actually a datetime type. If it is not, you will need to use Date.From ( DateTime.FixedLocalNow() 😞
= Table.AddColumn(#"Sorted Rows", "Filter Grtr 8 days", each if Duration.Days ( DateTime.FixedLocalNow()-[Date] ) < 8 then "Y" else "N", type text )
Hi Jenn,
I also have an error:
Not sure if I have done somethng wrong on my end. I added a custom column then pasted.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 5 | |
| 4 |