0

I try to check for each row if a DAX measure is <0. However, the check shall be done for each ID separately and not for the whole column. If TRUE, all rows related to this specific ID shall use measure2. If all rows within an ID are positive measure1 shall be used

Example

I tried to combine different DAX functions, like filter, if, etc. but didn´t get the job done.

1 Answer 1

1

I would try to implement a solution based on COUNTROWS, ALLEXCEPT and FILTER.

First count number of rows for a given ID using ALLEXCEPT.

Then do the same, but also use FILTER on the table returned by ALLEXCEPT where you use the required condition.

Compare the values and return the appropriate measure based on the logical predicate.

New measure =
VAR _id_count =
    COUNTROWS ( ALLEXCEPT ( 'Table', 'Table'[ID] ) )
VAR _id_count_where_value1_positive =
    COUNTROWS (
        FILTER ( 
            ALLEXCEPT ( 'Table', 'Table'[ID] ), 
            [Value1] > 0 
        )
    )
RETURN
    IF ( 
        _id_count = _id_count_where_value1_positive, 
        [Value1], 
        [Value2] 
    )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.