The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi everyone, hope you're having a good day.
I am writing as I'd like to create a column with an index based on year.
The column I have is the following (just showing few rows for example; data type "whole number"):
year_id |
2019 |
... |
2020 |
... |
2021 |
2021 |
... |
2022 |
2022 |
Every year has 365 records, namely 2020 repeats 365 times, 2021 repeats 365 times, ect.
The years present in the column start from 2019 and arrive to 2022.
I would like to create a new column next to each year assigning a number, from 1 to 365, where the count restarts with a new year.
For example:
year_id | index |
... | ... |
2021 | 364 |
2021 | 365 |
2022 | 1 |
... | ... |
The complication would be that 2020 is a leap year (and in the future there will be 2024 and so on, every 4 years).
Can anyone let me know how to that?
Thank you so much, wish you a good year
Michael
@Micgig , Do you have date column, else add index column in power query
A new column in dax
countx(filter(Table, [Year] =earlier([year]) && [Date] <=([Date])),[Date])
Or use index in place of date
https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi
Also, check
https://www.youtube.com/watch?v=7CqXdSEN2k4
You can also check dayofyear
User | Count |
---|---|
26 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
33 | |
13 | |
11 | |
9 | |
8 |