We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi all
I am trying to get the date (YYYY/MM/DD) in power query using an IF statement.
I need to have the year dynamic to today's year.
For example if Attribute column is "Production January (real and/or forecast) then return":
Today's Year/1/1 or in other words 2021/1/1
I am using the following M code:
= Table.AddColumn(#"Filtered Rows1", "Custom", each if [Attribute] = "Production January (real and/or forecast)" then Date.Month(#datetime(Date.Year(DateTime.LocalNow()),1,1))
else 0)
Below is the error:
Thanks.
Solved! Go to Solution.
Can't read the error (the picture is too small).
Looks like it says error in the cell so just click in the cell - not on the error - and it will display underneath.
--
Having said that, it looks like you are creating a #datetime and you want a #date, so try that
Can't read the error (the picture is too small).
Looks like it says error in the cell so just click in the cell - not on the error - and it will display underneath.
--
Having said that, it looks like you are creating a #datetime and you want a #date, so try that
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 10 | |
| 8 | |
| 7 | |
| 7 | |
| 5 |