Conner
Conner

Reputation: 307

COUNT DISTINCT values from multiple tables in Power BI

I need a measure that counts the distinct serial numbers from multiple tables;

Serial#
A
B
A
B
C
Serial#
A
D
C
D
C
B
C
D
A

I need my measure to be 4. There are 4 distinct Serial Numbers

I know how to make a table with the distinct values but I can't seem to create a measure that skips the step of creating an entirely new table. here is what I have tried:

COUNT(DISTINCT(UNION(VALUES(LABOR_HOURS[Serial #]),VALUES(OIL_SAMPLES[Serial#]), VALUES(UTILIZATION[SerialNumber]))))

thanks in advance for the help.

Upvotes: 2

Views: 7920

Answers (1)

RADO
RADO

Reputation: 8148

You are almost there:

 My Measure   =
    COUNTROWS (
        DISTINCT (
            UNION (
                VALUES ( LABOR_HOURS[Serial#] ),
                VALUES ( OIL_SAMPLES[Serial#] ),
                VALUES ( UTILIZATION[SerialNumber] )
            )
        )
    )

Distinct returns a table, so you need to count its rows (Count function needs a column, not table).

Upvotes: 3

Related Questions