Forum Discussion
IF less than today with dax
- 5 years ago
Greg is right - to be specific, change your formula to this
Table.AddColumn(#"Renamed Columns", "Custom", each if [#"Expiry"] <= DateTime.Date(DateTime.LocalNow()) then "Expired" else "Not-Expired")DateTime.LocalNow() is equivalent to NOW() in Excel.
Wrapping it in DateTime.Date() converts it to just the day - strips the time off of it, so it will do the comparison correctly. - 5 years ago
In Power Query? You could group by the new column and use COUNT as the aggregation, but I'd be inclined to that in DAX, as that is analysis. So
Expired Count = CALCULATE( COUNTROWS( MyTable ), MyTable[ExpiredField] = "Expired" )
Greg is right - to be specific, change your formula to this
Table.AddColumn(#"Renamed Columns", "Custom", each if [#"Expiry"] <= DateTime.Date(DateTime.LocalNow()) then "Expired" else "Not-Expired")
DateTime.LocalNow() is equivalent to NOW() in Excel.
Wrapping it in DateTime.Date() converts it to just the day - strips the time off of it, so it will do the comparison correctly.
This is great thanks how would i go about counting rows of expired and non expired from there then please ?
- edhans5 years agoCommunity Champion
In Power Query? You could group by the new column and use COUNT as the aggregation, but I'd be inclined to that in DAX, as that is analysis. So
Expired Count = CALCULATE( COUNTROWS( MyTable ), MyTable[ExpiredField] = "Expired" )- Jay20775 years agoHelper III
Thank you