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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ss89
Helper II
Helper II

Comparison between two columns from different queries

Hello Community,

 

I need to make a comparison between two columns, "Week Planned Out" and "Week Out" that come from two different queries.

When I try to do the IF formula and compare whether the "Week Planned Out" is greater than "Week Out", I cannot select columns from other different queries

How can I do this?

 

ss89_0-1674222057700.png

ss89_1-1674222078268.png

ss89_0-1674222445915.png

 

 

Thanks in advance for your help!

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @ss89 ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_1-1674458480855.png

Table2

vbinbinyumsft_2-1674458500256.png

Table3:

vbinbinyumsft_3-1674458515563.png

Table4:

vbinbinyumsft_4-1674458537646.png

Model:

vbinbinyumsft_0-1674458458252.png

2. try below dax formula

has relationship:

Column = IF([Sale]>RELATED('Table'[Cost]),"+","-")

vbinbinyumsft_5-1674458721114.png

 

no relationship:

Column =
VAR cost =
    LOOKUPVALUE ( 'Table 3'[Cost], 'Table 3'[Product], 'Table 4'[Product] )
RETURN
    IF ( [Sale] > cost, "+", "-" )

vbinbinyumsft_6-1674458789620.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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

2 REPLIES 2
v-binbinyu-msft
Community Support
Community Support

Hi @ss89 ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_1-1674458480855.png

Table2

vbinbinyumsft_2-1674458500256.png

Table3:

vbinbinyumsft_3-1674458515563.png

Table4:

vbinbinyumsft_4-1674458537646.png

Model:

vbinbinyumsft_0-1674458458252.png

2. try below dax formula

has relationship:

Column = IF([Sale]>RELATED('Table'[Cost]),"+","-")

vbinbinyumsft_5-1674458721114.png

 

no relationship:

Column =
VAR cost =
    LOOKUPVALUE ( 'Table 3'[Cost], 'Table 3'[Product], 'Table 4'[Product] )
RETURN
    IF ( [Sale] > cost, "+", "-" )

vbinbinyumsft_6-1674458789620.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

victoriamas
Frequent Visitor

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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