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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
asdf1608
Helper V
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.

 

Thanks in advance

1 ACCEPTED SOLUTION
amitchandak
Super User
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)

View solution in original post

2 REPLIES 2
amitchandak
Super User
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)

@amitchandak 

Thank you so much for your help

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors