Forum Discussion
IF statement with date
Hi All,
Sorry for the basic question, i am new to PowerBI and slowly learning it!
I have a table which has the following columns - Name (File Name), Extension (File type e.g .txt), size (size of the file), lastaccessed.
I would like to add a custom column to say that if the lastaccessed is within the last 1 year, call it hot data, otherwise if it's not been accessed in 1-3 years, call it cold, otherwise if it's older than 3 years then it will be archive data.
Please could someone advise on the best way to do this?
Many thanks in advance.
Matt
8 Replies
- edhansCommunity Champion
Do this in Power Query as a custom column. Look at the Date functions. The Date.IsInPreviousNYears() function in particular would seem to do exactly what you want.
- AnonymousNot applicable
Hi Edhans. Thanks for your quick response. I've just tried to add the query but it's not quite stacking up. Please see below.
Surely the files that were accessed the day before yesterday as per the query below, should be hot. As you can see in the screenshot there's a number of files that were accessed on 25th March. Maybe i'm not understanding it properly.
- edhansCommunity Champion
Try this: