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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SIBEIRABZ
New Member

Need help with comparing row

I need help with comparing two different rows using if else to make a custom colume in query

Logic : If "Rate" = EXPORT, E_EXPO, IMPORT or E_IMPO and if "Rate 2" = export and "Rate 1" of the same "Installation" = import then it results in a "y" which means they are in order (correct).

 

 If "Rate" does not = EXPORT, E_EXPO, IMPORT or E_IMPO then N.A

 

In other words, Rate 1 has to be import and Rate 2 has to be export to be correct.

If Rate 1 and Rate 2 are the same or in reverse order then it is incorrect.

 

Anything else that does not fullfilled these conditions if applicable will result in a "n" which mean incorrect.

 

Here is a before and after image of what I would need
Before:

SIBEIRABZ_0-1661928972510.png

 

After:

SIBEIRABZ_1-1661929025188.png

 

Any help or guide will be very helpful, thank you.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SIBEIRABZ ,

 

Here's my solution.

Sample data

vstephenmsft_4-1662106734715.png

 

1.Add two conditional columns to return 1 or 0.

vstephenmsft_2-1662106689056.png

vstephenmsft_1-1662106665035.png

vstephenmsft_3-1662106724144.png

 

2.Add the two columns.

vstephenmsft_5-1662106795833.png

vstephenmsft_6-1662106814661.png

 

3.Group by like the following.

vstephenmsft_7-1662106846176.png

vstephenmsft_8-1662106856965.png

Expand it.

vstephenmsft_9-1662106875496.png

 

4.Add a condintional to get the result.

vstephenmsft_10-1662106901927.png

vstephenmsft_11-1662106909533.png

 

 

 

 

Best Regards,

Stephen Tao

 

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
wdx223_Daniel
Super User
Super User

=Table.Combine(Table.Group(PreviousStepName,"Installation",{"n",each let a=if not List.ContainsAll({"EXPORT",
E_EXPO","IMPORT","E_IMPO"},[Rate]) then "N.A." else if List.RemoveItems([Rate 2],{null,"export"}={} and List.RemoveItems([Rate 1],{null,"import"})={} then "y" else "n" in Table.AddColumn(_,"in order",each a)})[n])

Anonymous
Not applicable

Hi @SIBEIRABZ ,

 

Here's my solution.

Sample data

vstephenmsft_4-1662106734715.png

 

1.Add two conditional columns to return 1 or 0.

vstephenmsft_2-1662106689056.png

vstephenmsft_1-1662106665035.png

vstephenmsft_3-1662106724144.png

 

2.Add the two columns.

vstephenmsft_5-1662106795833.png

vstephenmsft_6-1662106814661.png

 

3.Group by like the following.

vstephenmsft_7-1662106846176.png

vstephenmsft_8-1662106856965.png

Expand it.

vstephenmsft_9-1662106875496.png

 

4.Add a condintional to get the result.

vstephenmsft_10-1662106901927.png

vstephenmsft_11-1662106909533.png

 

 

 

 

Best Regards,

Stephen Tao

 

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

Thank you! This works just fine!!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors