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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JustNewbie
Helper I
Helper I

Conditional formatting need help

Hi,

 

I have a table below. Can I use the conditional formatting to perform the function:

If Label = I, always Date2 - Date1, if Date2 & Date1 are null then use Date4-Date3.

How to do this?

 

Label Date1Date2Date3Date4
I 1/11/20222/11/2022  
G  5/11/20226/11/2022 
I   1/11/20223/11/2022
G 1/11/20223/11/2022  
      
1 ACCEPTED SOLUTION

Hi @JustNewbie ,

 

Please create a new column:

Column = 
SWITCH (
    TRUE (),
    'Table'[Label] = "I"
        && (
            'Table'[Date1] <> BLANK ()
                && 'Table'[Date2] <> BLANK ()
        ), DATEDIFF ( 'Table'[Date1], 'Table'[Date2], DAY ),
    'Table'[Label] = "I"
        && (
            'Table'[Date1] = BLANK ()
                && 'Table'[Date2] = BLANK ()
        ), DATEDIFF ( 'Table'[Date3], 'Table'[Date4], DAY )
)

 

You will get a column like this and I think this is the result you want:

vyadongfmsft_0-1669366703016.png

 

If you have another question, please open another thread. In a post, we'd better only address one issue. This will cpntribute to the efficiency of problem solving.

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@JustNewbie , Not sure what is the role of conditional formatting here

 

if([Label] = "I" ,

Switch( True(),

isblank([Date1])  && isblank([Date2]) , [Date2] =[Date1],

[Date4] =[Date3],

blank()), blank())

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak thank you.

I have another condition.. If either Column A or Column B is blank then give me blank, else give me Column B date subtract Column A date in networkdays...
Thank u..

Hi @JustNewbie ,

 

Please create a new column:

Column = 
SWITCH (
    TRUE (),
    'Table'[Label] = "I"
        && (
            'Table'[Date1] <> BLANK ()
                && 'Table'[Date2] <> BLANK ()
        ), DATEDIFF ( 'Table'[Date1], 'Table'[Date2], DAY ),
    'Table'[Label] = "I"
        && (
            'Table'[Date1] = BLANK ()
                && 'Table'[Date2] = BLANK ()
        ), DATEDIFF ( 'Table'[Date3], 'Table'[Date4], DAY )
)

 

You will get a column like this and I think this is the result you want:

vyadongfmsft_0-1669366703016.png

 

If you have another question, please open another thread. In a post, we'd better only address one issue. This will cpntribute to the efficiency of problem solving.

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.