Forum Discussion

Daniel_Derbin's avatar
Daniel_Derbin
Frequent Visitor
3 years ago

Allexcept measure issue

Hi, 

The goal is to conditionally format a measure (background color) depending on selected filters.
Constrains, all data dim and fact are in one table.

In order to get to my final measure i had to create some nesting first:

1. Number of Vuln day = SUM('Fact daily'[count])
2. Vuln wo sev =
CALCULATE([Number of Vuln day],
    ALLEXCEPT('Fact daily', 'Fact daily'[Severity])
)
That allowed me to create a Divide measure - crucial for result as each of severities should add up to 100% in column total.
% of Vuln =
CALCULATE(
    DIVIDE([Number of Vuln day],[Vuln wo sev])
)

 

With conditional formatting of % of Vuln  



Now my problem starts when i try to filter report by department (also as a part of same table)
I seek for a measure that upon selection will calculate results to 100% for all severities, not only filtered part of data:


I can achieve this result by using Number of Vuln day measure and showing calculation by "Percent of column total", but then logic used to conditionally format fields won't apply.



Does anyone have an idea how to resolve this?

Lastly, measure for conditional formatting:

format risk = SWITCH (
    TRUE (),
     [% of Vuln] = BLANK(),"#fe9180",
    SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "0-30 days"
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "Critical"
        && [% of Vuln] >= 0.85, "#33ac7f",
    SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "31-60 days"
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "Critical"
        && [% of Vuln] <= 0.15
        && [% of Vuln] > 0, "#f7dd7e",
    (
        SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "0-30 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "31-60 days"
    )
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "High"
        && [% of Vuln] >= 0.95, "#33ac7f",
    SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "61-90 days"
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "High"
        && [% of Vuln] <= 0.1
        && [% of Vuln] > 0, "#f7dd7e",
    (
        SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "0-30 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "31-60 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "61-90 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "91-120 days"
    )
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "Medium"
        && [% of Vuln] >= 0.98, "#33ac7f",
    SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "121-180 days"
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "Medium"
        && [% of Vuln] <= 0.1
        && [% of Vuln] > 0, "#f7dd7e",
    (
        SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "0-30 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "31-60 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "61-90 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "91-120 days"
            || SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "121-180 days"
    )
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "Low"
        && [% of Vuln] >= 0.98, "#33ac7f",
    SELECTEDVALUE ( 'Fact daily'[Age categories] ) = "180-360 days"
        && SELECTEDVALUE ( 'Fact daily'[Severity] ) = "Low"
        && [% of Vuln] <= 0.1
        && [% of Vuln] > 0, "#f7dd7e",
       

    "#fe9180"
)


 



 



1 Reply