1
votes

I have this table:

IP  Technology  Status
IP1 T1  Passed
IP1 T1  Passed
IP1 T1  Failed
IP1 T2  Failed
IP1 T2  Failed
IP1 T2  Passed
IP2 T3  Passed
IP2 T3  Failed
IP3 T4  Passed
IP3 T4  Passed
IP3 T5  Passed
IP3 T5  Passed
IP3 T5  Passed
IP3 T5  Passed
IP3 T5  Passed
IP2 T6  Passed
IP2 T6  Passed
IP2 T6  Passed
IP2 T6  Passed

I have to remove some of the Technology (T2 and T6) and show the following summary table: (I am interested only in the ‘Passed’ results but left the ‘failed’ column for reference)

IP   Failed Passed  100% Passed
IP1  33%    67%     No
IP2  50%    50%     No
IP3  0%     100%    Yes

This is what I did: I created two temporary tables to calculate the number of passed tests and the total number of tests:

Table1 =
CALCULATETABLE (
    GROUPBY (
        'Table',
        'Table'[IP],
        'Table'[Status],
        "#Passed", COUNTAX ( CURRENTGROUP (), ( 'Table'[Status] = "Passed" ) )
    ),
    'Table'[Technology] = "T1"
        || 'Table'[Technology] = "T3"
        || 'Table'[Technology] = "T4"
        || 'Table'[Technology] = "T5"
)
Test2 =
CALCULATETABLE (
    GROUPBY (
        'Table',
        'Table'[IP],
        "#scan", COUNTAX ( CURRENTGROUP (), ( 'Table'[IP] ) )
    ),
    'Table'[Technology] = "T1"
        || 'Table'[Technology] = "T3"
        || 'Table'[Technology] = "T4"
        || 'Table'[Technology] = "T5"
)

In Table1, I added the total number of tests from Table2 using LOOKUPVALUE and calculated the ‘%Passed’.

When I want to get the ‘100% Passed’ flag (Yes/No) using IF statement:

100% Passed = IF(%'Table Test1'[%Passed]=1,"Yes","No")

I get this error message:

The following syntax error occurred during parsing: invalid token, Line1, Offset 4, %

Is it because the ‘%Passed’ is a calculated field? Do you know a way around? I’ve been working on this for days and I’m getting frustrated. Is there a more efficient way to get this result?

Thanks in advance for your help.

1
Where is %'Table Test1'[%Passed] defined? That doesn't appear to be a valid reference to anything.Alexis Olson
%Passed = divide('Table Test1'[#Passed],'Table Test1'[#Scan]) Elau
There's a % in front of the table name.Alexis Olson

1 Answers

1
votes

I personally prefer SUMMARIZE over GROUPBY although they are quite similar. You can use ADDCOLUMNS to add additional logic that refers to columns you calculated in your summarization to get the 100% Passed column.

Summary =
CALCULATETABLE (
    ADDCOLUMNS (
        SUMMARIZE (
            'Table',
            'Table'[IP],
            "% Passed", DIVIDE (
                CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Status] = "Passed" ),
                COUNTROWS ( 'Table' )
            )
        ),
        "100% Passed", IF ( [% Passed] = 1, "Yes", "No" )
    ),
    NOT ( 'Table'[Technology] IN { "T2", "T6" } )
)

Result