cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ausafonly
Regular Visitor

DAX query to return CompI have liant or Non Compliant based on the filter

ausafonly_0-1684672982571.png

Based on this data I want to create a calculated column or measure.

If compliance_status is both installed and required result should be Non compliant otherwise compliant in a new column.

I have no idea how to achieve it tried multiple ways but no luck.

Any suggestion how to achieve it.

3 REPLIES 3
Mrxiang
Helper II
Helper II

You can use the DAX language to create a computed column or metric to implement your requirements. Here is a sample DAX formula:

Compliance Status = IF(Table1[Compliance_Status] = "Installed" && Table1[Compliance_Status] = "Required",  "Non compliant", "Compliant")

This formula checks whether the value in the Compliance_Status column contains both "Installed" and "Required". If so, the result is "Non compliant", otherwise it is "Compliant". You can apply this formula to a new computed column or measure to display the results in a table.
v-shex-msft
Community Support
Community Support

Hi @ausafonly,

You can try to use the following measure formula to get the correspond statues count based on current hostname:

formula =
VAR currName =
    SELECTEDVALUE ( Table[HostName] )
VAR summary =
    SUMMARIZE (
        FILTER (
            ALLSELECTED ( Table ),
            [compliance_status] IN { "Installed", "Required" }
        ),
        [HostName],
        [compliance_status]
    )
RETURN
    IF (
        COUNTROWS ( FILTER ( summary, [HostName] = currName ) ) < 2,
        "Compliant",
        "Non compliant"
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Unfortunately it didn't worked as expected.

However I tried another method and it worked.

I have created a duplicate table and then used group by to achieve the solution.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors