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
Yahya
Helper I
Helper I

OR feature triggered by key

Hey community,

 

I'm trying to build a measure for which I don't know if I need it to be in Power Query, Calculated Column or measure.

 

On a similar table, this is what I'm trying to do

 

This is the table with the 'many' keys. 

KeyValue
12345null
12345SWAP
54321null
54321null
78945null
78945null
78945SWAP

Once a Key has the value SWAP, the other same Keys need to be considered a SWAP type

 

I have tried to use the OR feature as a measure, but I get strange results

 

Can you guys help me out with this?

 

With Regards,

Y.

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Yahya 

Add this as a new column in Data Model:

Swap_Key = 
VAR _Adv = CALCULATE(
    COUNTROWS('Table (4)'),
    'Table (4)'[Value]="SWAP")
RETURN

IF(_Adv>0,"SWAP",BLANK())

 

If you are satisfied with my answer, please mark it as a solution so others can easily find it.

Don't forget to give KUDOS ? to replies that help answer your questions


Subscribe to ExcelFort: Learn Power BI, Power Query and Excel

 

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

View solution in original post

6 REPLIES 6
Fowmy
Super User
Super User

@Yahya 

Add this as a new column in Data Model:

Swap_Key = 
VAR _Adv = CALCULATE(
    COUNTROWS('Table (4)'),
    'Table (4)'[Value]="SWAP")
RETURN

IF(_Adv>0,"SWAP",BLANK())

 

If you are satisfied with my answer, please mark it as a solution so others can easily find it.

Don't forget to give KUDOS ? to replies that help answer your questions


Subscribe to ExcelFort: Learn Power BI, Power Query and Excel

 

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

Hey Fowmy,

 

Thank you for your reply. This seems to work as expected 🙂 

amitchandak
Super User
Super User

@Yahya , what is the output you want

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

Hey amitchandak,

Thanks for the quick reply

 

The output I'd like is the following

When the calculation is done, filter out SWAP and distinct count the keys

and I'll make a 2nd measure to filter out the ones that aren't SWAP, in this case Blanks (null), and do the same distinct count of keys.

 

 

 

@Yahya , Try like


calculate(distinctcount(Table[key]),isblank(Table[Value]))

Or
calculate(distinctcount(Table[key]),Table[Value] ="SWAP")

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

How can I make sure this is correct?

If I do the first, I'll get the blank values, but a key may have 2 switches, either null or "SWAP". The result of my table should be

 

KeyValue

result

12345nullSWAP
12345SWAPSWAP
54321nullnull
54321nullnull
78945nullSWAP
78945nullSWAP
78945SWAPSWAP

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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 Solution Authors