DS_Geek
DS_Geek

Reputation: 53

create calculated last year date on selected month only in powerbi

I have data column name "Loss Date" I want to create new column "Policy Date" based on this column and the condition is if Month<4 then display last year date otherwise not. actually, I want to create Policy Date column and I want to display in this bar chart which is given below, can anybody helps me regarding this in PowerBI?

enter image description here

enter image description here

Upvotes: 0

Views: 38

Answers (1)

mkRabbani
mkRabbani

Reputation: 16908

In Power Query Editor, add a custom column with this below code-

=if Date.Month([loss date]) < 5 then "Apr-"& Text.From(Date.Year([loss date]) - 1) &" to Mar-"& Text.From(Date.Year([loss date]))  else "Apr-"& Text.From(Date.Year([loss date])) &" to Mar-"& Text.From(Date.Year([loss date]) +1)

Here is the output-

enter image description here

Now you can use that new column to your chart for generating Bars.

Upvotes: 1

Related Questions