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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
SDVN
Helper I
Helper I

I have an issue wbile using RELATED() function to create a measure.

Subject is the base table which contain unique subject names. This tabel is connected to different tables like "_common_ae_sif_signature_state", "_common_edc_query_status", "_common_form_raw". Now I want to get the distinct count of subject numbers based on the specified conditions. Can you help?

 

I have written: 

Measure =
CALCULATE(
    DISTINCTCOUNT(Subject[subject_number]),
    RELATED(_common_ae_sif_signature_state[form_signed]) = "No" ||
    RELATED(_common_casebook_signature_lock[cb_locked]) = "No" ||
    RELATED(_common_edc_query_status[query_state_name]) IN {"Open", "Answered"} ||
    RELATED(_common_form_raw[sdvcompletestate]) = "No" && RELATED(_common_form_raw[hassdvrequireditems]) = "Yes"
)
 
But I am geeting an error saying "The column '_common_ae_sif_signature_state[form_signed]' either doesn't exist or doesn't have a relationship to any table available in the current context."
 
I checked the name of the column and its correct and I checked the model view and its the subject table is connected to all the used tables. 
8 REPLIES 8
rohit1991
Super User
Super User

hi @SDVN ,

Your issue is likely due to RELATED() only working when there is a one-to-one or many-to-one relationship from the base table to the related table. If the relationship is one-to-many, you should use RELATEDTABLE() instead.

Fix: Use FILTER Instead of RELATED

Try modifying your measure using FILTER() and LOOKUPVALUE() instead of RELATED():

Measure =
CALCULATE(
    DISTINCTCOUNT(Subject[subject_number]),
    OR(
        LOOKUPVALUE(_common_ae_sif_signature_state[form_signed], _common_ae_sif_signature_state[subject_id], Subject[subject_id]) = "No",
        LOOKUPVALUE(_common_casebook_signature_lock[cb_locked], _common_casebook_signature_lock[subject_id], Subject[subject_id]) = "No",
        LOOKUPVALUE(_common_edc_query_status[query_state_name], _common_edc_query_status[subject_id], Subject[subject_id]) IN {"Open", "Answered"},
        AND(
            LOOKUPVALUE(_common_form_raw[sdvcompletestate], _common_form_raw[subject_id], Subject[subject_id]) = "No",
            LOOKUPVALUE(_common_form_raw[hassdvrequireditems], _common_form_raw[subject_id], Subject[subject_id]) = "Yes"
        )
    )
)

 

Again the error 😞
"Too many arguments were passed to the OR function. The maximum argument count for the function is 2."

SDVN_0-1738088506100.png

 

johnt75
Super User
Super User

RELATED requires a row context, which you don't have in this calculation. 

For this calculation you only need to place the filters on the required columns, so you can use

MEASURE =
CALCULATE (
    DISTINCTCOUNT ( Subject[subject_number] ),
    _common_ae_sif_signature_state[form_signed] = "No"
        || _common_casebook_signature_lock[cb_locked] = "No"
        || _common_edc_query_status[query_state_name]
        IN { "Open", "Answered" }
            || _common_form_raw[sdvcompletestate] = "No"
            && _common_form_raw[hassdvrequireditems] = "Yes"
)

I got this error sir, "The expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression."

SDVN_1-1738088625966.png

 

bhanu_gautam
Super User
Super User

@SDVN , Try using this alternative approach

 

Measure =
CALCULATE(
DISTINCTCOUNT(Subject[subject_number]),
FILTER(
RELATEDTABLE(_common_ae_sif_signature_state),
_common_ae_sif_signature_state[form_signed] = "No"
) ||
FILTER(
RELATEDTABLE(_common_casebook_signature_lock),
_common_casebook_signature_lock[cb_locked] = "No"
) ||
FILTER(
RELATEDTABLE(_common_edc_query_status),
_common_edc_query_status[query_state_name] IN {"Open", "Answered"}
) ||
FILTER(
RELATEDTABLE(_common_form_raw),
_common_form_raw[sdvcompletestate] = "No" && _common_form_raw[hassdvrequireditems] = "Yes"
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






I got the error again! 
"A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors