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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
StephenK
Resolver I
Resolver I

Calculating Flu Season from Date Table

Hey all,

 

I have a date table containing all dates within the last 3 years. I need to create a calculated column either in power query or dax that identifies the flu season. So for dates between 10/1/18 and 3/31/20, I would need an output of 2018 - 2019 Season, same for 2019 - 2020 and so on. How would I do this?

 

Thanks!

1 ACCEPTED SOLUTION

This column expression should work in your Date table

 

Flu Season =
SWITCH (
TRUE (),
Flu[Month] <= 3, YEAR ( Flu[Date] ) - 1 & "-"
& YEAR ( Flu[Date] ),
Flu[Month] >= 10, YEAR ( Flu[Date] ) & "-"
& YEAR ( Flu[Date] ) + 1,
"Off Season"
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
pranit828
Community Champion
Community Champion

Hi @StephenK 

Please provide sample Input and output.





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

@pranit828 

Date                                                Year   Month  FluSeason

Tuesday, September 25, 201820189Off Season
Wednesday, September 26, 201820189Off Season
Thursday, September 27, 201820189Off Season
Friday, September 28, 201820189Off Season
Monday, October 1, 20182018102018 - 2019
Tuesday, October 2, 20182018102018 - 2019
Wednesday, October 3, 20182018102018 - 2019
Thursday, October 4, 20182018102018 - 2019
Friday, October 5, 20182018102018 - 2019
Monday, October 8, 20182018102018 - 2019
Tuesday, October 9, 20182018102018 - 2019
Etc.Etc.Etc.Etc.
Thursday, March 28, 2019201932018 - 2019
Friday, March 29, 2019201932018 - 2019
Saturday, March 30, 2019201932018 - 2019
Sunday, March 31, 2019201932018 - 2019
Monday, April 1, 201920193Off Season

This column expression should work in your Date table

 

Flu Season =
SWITCH (
TRUE (),
Flu[Month] <= 3, YEAR ( Flu[Date] ) - 1 & "-"
& YEAR ( Flu[Date] ),
Flu[Month] >= 10, YEAR ( Flu[Date] ) & "-"
& YEAR ( Flu[Date] ) + 1,
"Off Season"
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


HI @StephenK 

 

Use the below logic.

IF(MONTH(table[date])>=8 && MONTH(table[date]) <=3

                                  ,IF(MONTH(table[date]) >=8, YEAR(table[date]), YEAR(table[date])-1) & " - " IF(MONTH(table[date]) >=8, YEAR(table[date])+1, YEAR(table[date]))

                                  ,"Off Season")





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.