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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
cheezy
Helper I
Helper I

Conditional formatting based on two values/fields in separate tables

trying to work out how i can achieve this and apply a conditional format (new to DAX):

 

for example two tables:

 

table 1                 table 2

Field 1                     Field 1            

A                           10

B                            15

C                            10

C                            60

A                            40

 

So just need something like this:

if         

table1.field 1 = A and table2.field1 <= 10  or  table1.field 1 = B and table2.field1 <= 15 or table1.field 1 = C and table2.field1 <= 20 then ' Value 1'

 

table1.field 1 = A and (table2.field1 > 10 or less than 20)  or  table1.field 1 = B and (table2.field1 > 15 and less than 30) or table1.field 1 = C and (table2.field1 > 20 and less than 40) then ' Value 2'

 

else

value 3

 

i could then apply conditional format based on value 1, 2 or 3

 

thanks

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @cheezy ,

If the two tables only have one column, maybe you can create a measure like this:

Measure = 
var _t1 = SELECTEDVALUE(Table1[Field1])
var _t2 = SELECTEDVALUE(Table2[Field1])
return
IF(
    ( _t1 = "A" && _t2 <=10 ) ||
    ( _t1 = "B" && _t2 <=15 ) ||
    ( _t1 = "C" && _t2 <=20 ),
    "Value1",
    IF(
        ( _t1 = "A" && ( _t2 >10 || _t2 < 20 ) ) ||
        ( _t1 = "B" && ( _t2 >15 && _t2 < 30 ) ) ||
        ( _t1 = "C" && ( _t2 >20 && _t2 < 40 ) ),
        "Value2",
        "Value3"
    )
)

table.png

 

Best Regards,
Yingjie Li

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
v-yingjl
Community Support
Community Support

Hi @cheezy ,

If the two tables only have one column, maybe you can create a measure like this:

Measure = 
var _t1 = SELECTEDVALUE(Table1[Field1])
var _t2 = SELECTEDVALUE(Table2[Field1])
return
IF(
    ( _t1 = "A" && _t2 <=10 ) ||
    ( _t1 = "B" && _t2 <=15 ) ||
    ( _t1 = "C" && _t2 <=20 ),
    "Value1",
    IF(
        ( _t1 = "A" && ( _t2 >10 || _t2 < 20 ) ) ||
        ( _t1 = "B" && ( _t2 >15 && _t2 < 30 ) ) ||
        ( _t1 = "C" && ( _t2 >20 && _t2 < 40 ) ),
        "Value2",
        "Value3"
    )
)

table.png

 

Best Regards,
Yingjie Li

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

many thanks Yingjie , your solutions works a treat.

amitchandak
Super User
Super User

@cheezy , does these tables have any common field. If not then you have to use crossjoin and summarize

 

example

table2 = SUMMARIZE(filter(CROSSJOIN(Sheet1,Table),Table[Date]>=(Sheet1[last Date]) && Table[Date]<=(Sheet1[Start Date])),Sheet1[ID],Sheet1[Name],table[Status],Table[Date],Sheet1[Start Date],Sheet1[End Date])

 

Filter is optional. you can create the column in summarize as per need

 

or selectcolumns and crossjoin

https://docs.microsoft.com/en-us/dax/selectcolumns-function-dax

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors