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
angie9127
New Member

Condition for month/year not working

Can anyone help with this formula? I created a new column in my calendar table to name the quarter as follows. The first block works well, but when it has to look for the month again, it stops working and leaves everything blank as if there were no more conditions to look for.

 

FiscalQtr =
    IF(MONTH(Calendario[Date])in{10, 11, 12},
        IF(YEAR(Calendario[Date])in{2021},"FY2021Q3",
        IF(YEAR(Calendario[Date])in{2022},"FY2122Q3",
        IF(YEAR(Calendario[Date])in{2023},"FY2223Q3",
        IF(YEAR(Calendario[Date])in{2024},"FY2324Q3",
    IF(MONTH(Calendario[Date])in{1, 2, 3},
        IF(YEAR(Calendario[Date])in{2021},"FY2021Q4",
        IF(YEAR(Calendario[Date])in{2022},"FY2122Q4",
        IF(YEAR(Calendario[Date])in{2023},"FY2223Q4",
        IF(YEAR(Calendario[Date])in{2024},"FY2324Q4",
    IF(MONTH(Calendario[Date])in{4, 5, 6},
        IF(YEAR(Calendario[Date])in{2021},"FY2021Q1",
        IF(YEAR(Calendario[Date])in{2022},"FY2122Q1",
        IF(YEAR(Calendario[Date])in{2023},"FY2223Q1",
        IF(YEAR(Calendario[Date])in{2024},"FY2324Q1",
    IF(MONTH(Calendario[Date])in{7, 8, 9},
        IF(YEAR(Calendario[Date])in{2021},"FY2021Q2",
        IF(YEAR(Calendario[Date])in{2022},"FY2122Q2",
        IF(YEAR(Calendario[Date])in{2023},"FY2223Q2",
        IF(YEAR(Calendario[Date])in{2024},"FY2324Q2"))))))))))))))))))))
1 ACCEPTED SOLUTION
Payeras_BI
Super User
Super User

Hi @angie9127 ,

Try this:

Your column = 
SWITCH(
    TRUE(),
    MONTH('Date'[Date]) in {10,11,12},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q3",
    MONTH('Date'[Date]) in {1,2,3},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q4",
    MONTH('Date'[Date]) in {4,5,6},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q1",
    MONTH('Date'[Date]) in {7,8,9},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q2"
)

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

3 REPLIES 3
Payeras_BI
Super User
Super User

Hi again @angie9127 ,
Or this:

 

Your column ii =
"FY" & RIGHT ( YEAR ( 'Calendario'[Date] ) - 1, 2 ) & RIGHT ( YEAR ( 'Calendario'[Date] ), 2 ) 
& "Q" & IF ( QUARTER ( 'Calendario'[Date] ) = 1, 4, QUARTER ( 'Calendario'[Date] ) - 1 )

 

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Payeras_BI
Super User
Super User

Hi @angie9127 ,

Try this:

Your column = 
SWITCH(
    TRUE(),
    MONTH('Date'[Date]) in {10,11,12},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q3",
    MONTH('Date'[Date]) in {1,2,3},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q4",
    MONTH('Date'[Date]) in {4,5,6},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q1",
    MONTH('Date'[Date]) in {7,8,9},"FY"&RIGHT(YEAR('Date'[Date])-1,2)&RIGHT(YEAR('Date'[Date]),2)&"Q2"
)

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

Thanks J.Payeras - this really helped solving the problem. 

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