I have a column called offer_date which has the followig value: Wednesday, 27 January, 2016 .
I am trying to compare this date with today's date in power bi DAX formula.
IF(DATEVALUE(offer_date) >= today(), "good job"
The problem is that the comparison is not happening for some reason. Does anyone know how to convert the text date into datetime and compare it with today() ?
I was able to convert the initial text date to datetime. So from Wednesday, 27 February, 2017 to 02/27/2017 12:00:00 AM . I went under the modeling tab and changed the data type from text to datetime.
The only problem is that the foloowing is still not working:
IF(DATEVALUE(offer_date) >= today(), "good job", "")
Note that 02/27/17 is greater than today's date (02/20/17). So, it should be displaying "good job", but it's not.
This is happening because you have values (more like errors) that cannot be coverted to Date!!!
Blanks would not cause this - but text that cannot be coverted to a date say 4/1/
But I am not getting any such error.
Hi @kaka,
Please try to click the Refresh button to refresh the data. Also update the desktop to latest version 2.43.4647.541.
You can also create a calculated column to return current date,
CurrentDate=Today()
Then create a calculated column:
IF(DATEVALUE(offer_date) >= CurrentDate, "good job", "")
If issue persists, would you please share the screenshots about the DAX and results for our analysis? If possible, please share the .pbix file.
Best Regards,
Qiuyun Yu
@kaka The comparison is actually happening!
You are not seeing anything because you don't have anything in the [ResultIfFalse] part of the IF function
You need to reverse >= to <=
EDIT: I'm assuming this is an Offer Made on Date so you want to it be less than today indicating that Offer has been made!
Go to the data model modeling tab in Power BI Desktop (or in Query Editor) and set the data type to "Date". Then you can do something like this in DAX (slightly different in M code):
Column = IF(DAY([Date]) = DAY(TODAY()) && MONTH([Date]) = MONTH(TODAY()) && YEAR([Date]) = YEAR(TODAY()),"good job","bad job")
What happens when you just create a column with the following code
new column = DATEVALUE('mytable'[offer_date])
secondly, do you round out your IF statement as follows?
new Column2 = if(DATEVALUE('myTable'[offer_Date]>=Today()),"Good Job","")
Oh and are you creating calculated columns as opposed to calculated Measures?
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!
User | Count |
---|---|
106 | |
80 | |
72 | |
48 | |
47 |
User | Count |
---|---|
157 | |
89 | |
81 | |
69 | |
67 |