Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
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
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.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHi 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.
Try this:
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingI'd need to see your data. It will work. DateIsInPreviousNDays() simply returns true or false. Your original formula was comparing a date to the result DateIsInPreviousDays() but since the latter returns true/false, it will never equal any date, so the If statement always returned the FALSE result.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHI edhans, this is my data.
I'd like an additional column called 'hot' and then 'cold' and then 'Archive'. I think i'm struggling with the logic with PowerQuery. I've ordered a book that's arriving today so i can further learn it. I normally deal with PowerShell so dates are slightly different in that language.
This is so i can then add a visual to say Hot would be a certain price for data, COld would be another price, then Archive would be another price. Maybe this is easier with 3x columns (Hot, Cold, Archive)?
Thanks again.
@edhans wrote:I'd need to see your data. It will work. DateIsInPreviousNDays() simply returns true or false. Your original formula was comparing a date to the result DateIsInPreviousDays() but since the latter returns true/false, it will never equal any date, so the If statement always returned the FALSE result.
Managed to get the Hot or Cold working, however it's creating duplicate rows for some reason?
The formula isn't creating extra rows. You have a merge that is causing that. I just tested it with random data and it works just fine. This just looks for dates in the previous 10 days. If so, it is Hot, otherwise Cold. I didn't bother changing future dates to show something different.
Please post a link to your model or a more complete set of data than screenshots to help with the merge issue.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingUser | Count |
---|---|
84 | |
80 | |
72 | |
71 | |
55 |
User | Count |
---|---|
108 | |
106 | |
93 | |
85 | |
67 |