cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper I

## How to write calculation to classify Current FY and Previous FY from a Date column?

Hello guys,

I'm new to Power BI,  and trying to learn how to write DAX and other calculated columns.

I have date colum only with 3 years data, and the financial year starts from July to June.

Condition is:

1) IF Date <= 01/07/2021  AND Date >= 30/06/2022   THEN "Current FY"

ELSE Date >=30/06/2021 THEN "Previous FY"

END

Need to calcualte current Financial year dynamically without hardcoding the values in the calculation.

Expected out of the calculated column should be below (Period) as an example.

 Date Period 1/01/2019 Previous  FY 1/02/2019 Previous FY 1/03/2019 Previous FY 1/04/2019 Previous FY 1/05/2019 Previous FY 1/06/2019 Previous FY 1/07/2019 Previous FY 1/08/2019 Previous FY 1/09/2019 Previous FY 1/10/2019 Previous FY 1/11/2019 Previous FY 1/12/2019 Previous FY 1/01/2020 Previous FY 1/02/2020 Previous FY 1/03/2020 Previous FY 1/04/2020 Previous FY 1/05/2020 Previous FY 1/06/2020 Previous FY 1/07/2020 Previous FY 1/08/2020 Previous FY 1/09/2020 Previous FY 1/10/2020 Previous FY 1/11/2020 Previous FY 1/12/2020 Previous FY 1/01/2021 Previous FY 1/02/2021 Previous FY 1/03/2021 Previous FY 1/04/2021 Previous FY 1/05/2021 Previous FY 1/06/2021 Previous FY 1/07/2021 Current FY 1/08/2021 Current FY 1/09/2021 Current FY 1/10/2021 Current FY 1/11/2021 Current FY 1/12/2021 Current FY

Please let me know how to achieve it.

Dee

1 ACCEPTED SOLUTION
Super User

@Deeintu , Try a new column in DAX like

new column =
var _month = month(today() )
var _year = year(today())
var _st = date(if(_month <=6, _year -1, _year),7,1)
var _end = date(if(_month <=6, _year , _year)+1,6,30)
return
if([date] >= _st && [Date] <=_end , "Current FY", "Previous FY")

2 REPLIES 2
Super User

@Deeintu , Try a new column in DAX like

new column =
var _month = month(today() )
var _year = year(today())
var _st = date(if(_month <=6, _year -1, _year),7,1)
var _end = date(if(_month <=6, _year , _year)+1,6,30)
return
if([date] >= _st && [Date] <=_end , "Current FY", "Previous FY")

Helper I

Hi Amit,

Thank you very much!

Now I understood how to declare variables and include them in the calculation.

Regards

Dee

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors