Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
I'm fairly new to Power Bi and I came upon this problem. I wanted to extract the year from a date in order to properly use is as categorical data on a graph.
I looked at a couple of solution online and one mentionned using the STAROFYEAR function. From what I understand, it should return 01-Jan-"year". For some reason I'm getting all kind of dates returned. 20-Sep-2006 returns 13-Feb-2006 and 01-Oct-2009 returns 06-Jan-2009.
Years for all of them is correct, and months are exclusively January and February. (There are about 20,000 items in the list). I also noticed that all dates from the same year have the same Day-Month value. I thought it might be a date format thing, but as far as January 1st is concerned, dd/mm/yyyy or mm/dd/yyy is the same.
Any help on this would be appreciated.
Solved! Go to Solution.
@VincentCWork, Try the below calculation,
= DATE(YEAR(<DateColumn>),1,1)
STARTOFYEAR DAX Function has a few requirements, Please check this link for more details
@VincentCWork, Try the below calculation,
= DATE(YEAR(<DateColumn>),1,1)
STARTOFYEAR DAX Function has a few requirements, Please check this link for more details
This worked like a charm to get the 1st day of the year.
As this is a solution to the help I requested I accepted it as a solution.
Saddly, it turns out that this is not the reason why my data didn't show up correctly when switching it up to "Categorical" type. If you have any tips about that one, please consult my other thread here:
https://community.powerbi.com/t5/Desktop/Display-all-dates-on-a-staked-column-chart/m-p/3236435
Oh, so since I haven't got an entry for EVERY day of the year, it would give me the FIRST day that I do have for that year? Explaining why all dates are at the start of the year and the same for those in the same year.
Will try your solution first thing tomorrow, but it's nice to know why it didn't work.
Thanks, will return to mark this as a solution if it pans out.
User | Count |
---|---|
85 | |
79 | |
64 | |
52 | |
46 |
User | Count |
---|---|
101 | |
44 | |
41 | |
39 | |
36 |