Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe'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
Sorry if I've already posted this but can't find my original post!
I'm trying to group my datetime column "modify time" so it contains data like this:
New column name: Last Modified
Today: 4
Yesterday: 7
2 days ago: 3
3 days ago: 4
I have the datetime column but I also have "Modified Date" which is a date column to work with.
I'm struggling with the statement, I assume I want something like this:
IF [Modified Date] = TODAY THEN "Today" ELSE IF [Modified Date] > TODAY -1 AND < TODAY THEN "Yesterday" etc.
Any help would be greatly appreciated!
Solved! Go to Solution.
Not sure if it's the most elegant solution but I went with this in the end:
@Anonymous , In you date table create a column like this
Date Type = SWITCH(TRUE(),'Date'[Date]=TODAY(),"Today"
,'Date'[Date]=TODAY()-1,"Yesterday"
,'Date'[Date]=TODAY()-2,"2 Days Ago"
,'Date'[Date]&"")
Sort it on Date
Join it date of date table with date of your table
@amitchandak Thank you, I think this would only work if I was to continue with 3,4,5,6 days etc. but I'd like to expand the range the older the data is so for example last week, last month which I don't think can be done with a switch? I'd need to use an IF statement to achieve this- Is that correct?
Hi @Anonymous ,
Try to create the column.
Column = var diff = DATEDIFF('Table (2)'[Modified Date],TODAY(),DAY)
return SWITCH(TRUE(),
diff<7,diff&" days ago",
7<=diff&&diff<30,TRUNC(diff/7)&" weeks ago",
diff>=30,TRUNC(diff/30)&" months ago")
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Not sure if it's the most elegant solution but I went with this in the end:
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 |
|---|---|
| 55 | |
| 35 | |
| 31 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 38 | |
| 35 | |
| 25 |