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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Complicated Conditional conditions Column

I have a bit complex goal I want to achieve, not sure if its possible at all.

 

I want to include a custom column that has a number of conditions based on vairus fields. 

 

If ([Date] = (april 26th 2021) and [Time] between (1:30 am and 8:30 Am) and [SLA Met]=0 and [Service Desk]="EUC" then "OK" else "Not OK"

 

Is something like this possible?

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Yes, possible in both Power Query and DAX, but the implementation largely depends on whether your fields are all in the same table or not.

 

Assuming that they are, go to Add Column tab in Power Query, select Custom Column, then enter something like the following formula in the calculation window. I'd recommend doing this in Power Query as DAX calculated columns should only really be used as an absolute last resort due to the memory use they require.

 

 

if [Date] = #date(2021, 26, 04)
  and [Time] >= #time(01, 30, 00)
  and [Time] <= #time(08, 30, 00)
  and [SLA Met] = 0
  and [Service Desk] = "EUC"
then "OK"
else "Not OK"

 

 

If they aren't in the same table, you will either need to merge your tables in Power Query before adding this column, or you will need to create the column in DAX, using RELATED() to reference fields that aren't in the same table (presuming that there is a suitable relationship in place between the tables).

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Yes, possible in both Power Query and DAX, but the implementation largely depends on whether your fields are all in the same table or not.

 

Assuming that they are, go to Add Column tab in Power Query, select Custom Column, then enter something like the following formula in the calculation window. I'd recommend doing this in Power Query as DAX calculated columns should only really be used as an absolute last resort due to the memory use they require.

 

 

if [Date] = #date(2021, 26, 04)
  and [Time] >= #time(01, 30, 00)
  and [Time] <= #time(08, 30, 00)
  and [SLA Met] = 0
  and [Service Desk] = "EUC"
then "OK"
else "Not OK"

 

 

If they aren't in the same table, you will either need to merge your tables in Power Query before adding this column, or you will need to create the column in DAX, using RELATED() to reference fields that aren't in the same table (presuming that there is a suitable relationship in place between the tables).

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Fowmy
Super User
Super User

@Anonymous 
Add the following New Column to your table in the model (NOT power Query): 

Fowmy_0-1622731250263.png

 



New Column =
IF (
    [Date] = DATE ( 2021, 4, 26 )
        && (
            [Time] >= TIME ( 1, 30, 0 )
                && [Time] <= TIME ( 8, 30, 0 )
        )
        && [SLA Met] = 0
        && [Service Desk] = "EUC",
    "OK",
    "Not OK"
)



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Sure mate! You can do it on Power Query: Add Custom Column. There you can apply all the conditions you want. Just be careful to separate the statements with brackets and commas. Also, since you are going to provide specific values, ensure to type the exact value since it is case & string sensitive. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors