Forum Discussion
Anonymous
3 years agoNot applicable
Grouping clients using a DATEDIFF & TODAY( ) function
I am trying to categorize clients by their sale date, which should be simple but I am not sure how to transate the command into Power BI syntax. I have three categories: client sales date < 180 days ...
- Anonymous3 years ago
I figured it out. Power BI it required me to break it into two different items (including one that controlled for blanks or I lost customer IDs).
First, I had to create the datediff function: Days since Sale= DATEDIFF('table'[sale date], TODAY( ), day)
Then I had to put that measure into a column to break the values into groups. Once it was a column, I can use it as a column or filter by its groups:
Days since sale column = SWITCH( TRUE( ), 'table' [days since sale], > 180, "over 180 days",
'table'[days since sale] <= 180 && 'table'[days since sale] > 0, "closed within the last 180 days",
'table'[days since sale] = blank ( ), "hasn't closed yet")
Ahmedx
Super User
3 years agoshow what the error is and is it possible to see an example from the date column