cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamehElghazaly
Frequent Visitor

If condition isn't working with all column

Hi Guys,

Am trying below IF formula and its not working with all column , can you please advise why or how can i solve it.

"IF('Calender Test'[Quarter]="Q1","DB"&FORMAT(DATEADD('Calender Test'[Date].[Date],1,YEAR),"YY"),IF('Calender Test'[Quarter]="Q4","DB"&FORMAT(DATEADD('Calender Test'[Date].[Date],2,YEAR),"YY"),'Calender Test'[Quarter]))"

SamehElghazaly_0-1674349096919.png

 



1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Does this calculated column formula work

=F('Calender Test'[Quarter]="Q1","DB"&YEAR('Calender Test'[Date])+1,IF('Calender Test'[Quarter]="Q4","DB"&YEAR('Calender Test'[Date])+2,'Calender Test'[Quarter]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

Does this calculated column formula work

=F('Calender Test'[Quarter]="Q1","DB"&YEAR('Calender Test'[Date])+1,IF('Calender Test'[Quarter]="Q4","DB"&YEAR('Calender Test'[Date])+2,'Calender Test'[Quarter]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you Guyes i figured it out :).

Thank you Ashish it worked but its not showin correctly in the Matrix as below.
the right arrangment asper the date should be DB2023 Q2 Q3 DB2024. any recommendation ?

SamehElghazaly_0-1674381227920.png

 

FreemanZ
Community Champion
Community Champion

hi @SamehElghazaly 

what do you get if you try like:

"IF('Calender Test'[Quarter]="Q1","DB"&FORMAT(DATEADD('Calender Test'[Date],1,YEAR),"YY"),IF('Calender Test'[Quarter]="Q4","DB"&FORMAT(DATEADD('Calender Test'[Date],2,YEAR),"YY"),'Calender Test'[Quarter]))"

same answer

jdbuchanan71
Super User
Super User

@SamehElghazaly 

I don't see anything wrong with the DAX but you don't need to use 'Calender Test'[Date].[Date], you can just use 'Calender Test'[Date].  Also, it's easier to use a SWITCH statement instead of nested IFs so it would look like this.

Internal Q =
SWITCH (
    TRUE (),
    'Calender Test'[Quarter] = "Q1", "DB" & FORMAT ( DATEADD ( 'Calender Test'[Date], 1, YEAR ), "YY" ),
    'Calender Test'[Quarter] = "Q4", "DB" & FORMAT ( DATEADD ( 'Calender Test'[Date], 2, YEAR ), "YY" ),
    'Calender Test'[Quarter]
)

What output are you trying to get?

am trying to replace all Q1 +2 row year to be shown as (1/1/2022 and Q1 to appear as DB24) in date column 

Arul
Super User
Super User

@SamehElghazaly ,

What is the expected result here?

Thanks,

Arul

Regards,
Arul
If I answered your question kindly mark my post as a solution and a kudo would be appreciated.

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors