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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jacccodezwart
Helper I
Helper I

Check if all values exist

Hi there,

 

Here is the situation :

I have contractlines, which hold an activity code. It looks like this :

jacccodezwart_2-1664277565497.png

 

 

Contractnumber is 4864, and the activity codes are O03 and O29

 

Now I have orderlines which contain an activity code and an contractnumber, that looks like this :

jacccodezwart_4-1664277620119.png

 

The question is . . how do I check that ALL the activity-codes from the contract are in the order ? It can be that an order holds more activity codes than the contract, which is okay, but it should return true in that case as well.

 

All help is welcome

 

Thanks in advance.

 

Jacco

 

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Hi @jacccodezwart 

Here's one way to do it.  This is a measure that will give you True or False for each OrderKey.

I've assumed your model is 2 disconnected tables

PaulOlding_0-1664280724579.png

Has All Activity Codes = 
VAR _Orders = 
SELECTCOLUMNS(orderlines, 
    "ContractNumber", orderlines[OrderContractNumber] & "",
    "ActivityKey", orderlines[ActivityKey] & ""
)
VAR _Contracts = 
SELECTCOLUMNS(contractlines, 
    "ContractNumber", contractlines[ContractNumber] & "",
    "ActivityKey", contractlines[ActivityKey] & ""
)
VAR _Joined = 
NATURALINNERJOIN(_Contracts, _Orders)
VAR _ContractActivityCount = 
CALCULATE(
    COUNTROWS(contractlines),
    contractlines[ContractNumber] = SELECTEDVALUE(orderlines[OrderContractNumber])
)
RETURN
    _ContractActivityCount <= COUNTROWS(_Joined)

 

The '& ""' are there to break lineage, so NATURALINNERJOIN will combine _Orders and _Contracts

View solution in original post

2 REPLIES 2
jacccodezwart
Helper I
Helper I

@PaulOlding Thanks for you reply. Implemented it and works like a charm !!

PaulOlding
Solution Sage
Solution Sage

Hi @jacccodezwart 

Here's one way to do it.  This is a measure that will give you True or False for each OrderKey.

I've assumed your model is 2 disconnected tables

PaulOlding_0-1664280724579.png

Has All Activity Codes = 
VAR _Orders = 
SELECTCOLUMNS(orderlines, 
    "ContractNumber", orderlines[OrderContractNumber] & "",
    "ActivityKey", orderlines[ActivityKey] & ""
)
VAR _Contracts = 
SELECTCOLUMNS(contractlines, 
    "ContractNumber", contractlines[ContractNumber] & "",
    "ActivityKey", contractlines[ActivityKey] & ""
)
VAR _Joined = 
NATURALINNERJOIN(_Contracts, _Orders)
VAR _ContractActivityCount = 
CALCULATE(
    COUNTROWS(contractlines),
    contractlines[ContractNumber] = SELECTEDVALUE(orderlines[OrderContractNumber])
)
RETURN
    _ContractActivityCount <= COUNTROWS(_Joined)

 

The '& ""' are there to break lineage, so NATURALINNERJOIN will combine _Orders and _Contracts

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.