Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
okletsgo
Advocate II
Advocate II

How to calculate a season column?

I'm trying to create a calucted column to calculate season via the DAX formula below but I get error

 

 

Season = 
IF (
    'Date'[MonthNo] >= 9
        && 'Date'[MonthNo]<= 12,
   'Date'[Year] & "-"
        & 'Date'[Year] + 1,
    'Date'[Year] - 1
        & "-"
        & 'Date'[Year]
)

 

The table look like this.

ca.png

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @okletsgo ,

 

Based on my test, I did not get any issue here. Are the columns are calculated columns in your formula in your scenario? Then you will get circular dependency error. You can refer to this third - party bolg.

 

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

 

Btw, please try to use the updated one.

Season = 
IF (
    MONTH('Date'[Datum])>= 9
        && MONTH('Date'[Datum])<= 12,
   YEAR('Date'[Datum]) & "-"
        & YEAR('Date'[Datum]) + 1,
    YEAR('Date'[Datum]) - 1
        & "-"
        & YEAR('Date'[Datum])
)
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
okletsgo
Advocate II
Advocate II

I have a date column, and I wanna create a season column from it.

The date column look like 2016-02-10 and etc.....

 

The season column I want gonna look like this format below:

2014/2015

2015/2016

2016/2017

 

Any idea or example how I can do it in Power Query?

If the date column in your file looks like 2016-02-10, then you'll need to change it to be a real date. Power Query will do this automatically if you just change the data type to date. Then it will be 2/10/2016 (US format).

 

Now you can easily get a new column with the info you need.

 

=Text.From(Date.Year([Date])) & "/" & Text.From(Date.Year([Date])+1)

You can get fancy with date logic to see if the date is in the 4th quarter or whatever to decide when to switch to a new season, but the above will take any date in 2016 and cause the Season to be 2016/2017.

 

Be sure you assign that type as Text when done.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
v-frfei-msft
Community Support
Community Support

Hi @okletsgo ,

 

Based on my test, I did not get any issue here. Are the columns are calculated columns in your formula in your scenario? Then you will get circular dependency error. You can refer to this third - party bolg.

 

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

 

Btw, please try to use the updated one.

Season = 
IF (
    MONTH('Date'[Datum])>= 9
        && MONTH('Date'[Datum])<= 12,
   YEAR('Date'[Datum]) & "-"
        & YEAR('Date'[Datum]) + 1,
    YEAR('Date'[Datum]) - 1
        & "-"
        & YEAR('Date'[Datum])
)
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
judspud
Solution Supplier
Solution Supplier

Hi @okletsgo 

 

What error are you receiving? 

I have just tried your formula and it is working as expected for me

 

Thanks,

George

eee.png

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.