cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper V

## Need help with the if condition for year and month

To convert the following tableau calculated field to Power BI Dax, which I faced issue while doing this.

STR(if year(TODAY()) = year([Calender]) and month(TODAY())= MONTH(Calender]]) then 1
elseif year(TODAY()) = year(Calender]) and
(month(TODAY())- MONTH(Calender])) >=0 then 1
elseif year(TODAY())-1 = year(Calender]) and
(month(TODAY())- MONTH(Calender])) < 0 then 1
else 0 end)

Help with this is really appreciated.

1 ACCEPTED SOLUTION
Super User

@asdf1608 ,Assuming calendar is name of date column, a new column like

Switch( True() ,
year(TODAY()) = year([Calender]) && month(TODAY())= MONTH(Calender]]), 1
year(TODAY()) = year(Calender]) && (month(TODAY())- MONTH(Calender])) >=0 ,1
year(TODAY())-1 = year(Calender]) && (month(TODAY())- MONTH(Calender])),1,0)

2 REPLIES 2
Super User

@asdf1608 ,Assuming calendar is name of date column, a new column like

Switch( True() ,
year(TODAY()) = year([Calender]) && month(TODAY())= MONTH(Calender]]), 1
year(TODAY()) = year(Calender]) && (month(TODAY())- MONTH(Calender])) >=0 ,1
year(TODAY())-1 = year(Calender]) && (month(TODAY())- MONTH(Calender])),1,0)

Helper V

Thank you so much for your help

Announcements

#### 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.