Forum Discussion

AndreaBracco's avatar
AndreaBracco
Regular Visitor
1 year ago
Solved

Problems with row/filter context

Hi all,

I am quite new to Power BI and I have the following issue. I have the following visual, where the column "Check_Global" is actually a measure.

The measure is computed as follows.

 
Check_Global = if(or(
                               sumx('CHP Units','CHP Units'[Check_Hours])>0,
                               sumx('CHP Units','CHP Units'[Check_EE])>0
                                   ),
                             1,blank() )

My question is: why is not the total equal to the column sum? In this example, I aspected to get 12.
Basically, the Check_Global should tell me how many days have corrupted data.

I think it is related to row\filter context, but I am very confused about it...
And, as follows, I report another issue I think always related to row\filter context.
In the following matrix, the measure "CB" is showed by ID and Month.

As you can see, ID totals are corrected but month totals no!
Please not that this calculation is very complex, so the ID sum could be not equal to the monthly sum...however it is useful to have a graphical representation of the monthly data. Instead, the sum over all ID for each month should be the exact sum!

The measure is computed as follows.

 

 

I humbly ask your help!

Thanks

Andrea

  • Hi,

    I am not sure how your semantic model looks like, but please try something like below whether it works.

    Check_Global =
    SUMX (
        VALUES ( calendar_table[date_column] ),
        CALCULATE (
            IF (
                OR (
                    SUMX ( 'CHP Units', 'CHP Units'[Check_Hours] ) > 0,
                    SUMX ( 'CHP Units', 'CHP Units'[Check_EE] ) > 0
                ),
                1,
                BLANK ()
            )
        )
    )
    

3 Replies

  • Hello AndreaBracco 

    Could you please provide sample data that fully represents your issue or question in a usable format, rather than a screenshot? Ensure the dataset is anonymized and does not contain any sensitive or unrelated information.

     

    Additionally, it would be very helpful if you could share the expected outcome based on the provided data - this can be in any format, including a screenshot. Having a clear reference for comparison will significantly improve the chances of getting the correct solution in the first response.

     

    For best practices, you may find the following links useful:

     

    Thanks,
    Udit

    🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
    ✨ Visit My Linktree: LinkTree

    Proud to be a Super User

  • Hi,

    I am not sure how your semantic model looks like, but please try something like below whether it works.

    Check_Global =
    SUMX (
        VALUES ( calendar_table[date_column] ),
        CALCULATE (
            IF (
                OR (
                    SUMX ( 'CHP Units', 'CHP Units'[Check_Hours] ) > 0,
                    SUMX ( 'CHP Units', 'CHP Units'[Check_EE] ) > 0
                ),
                1,
                BLANK ()
            )
        )
    )