admin 管理员组

文章数量: 1086019

I have a table UPS with 2 columns

location Maint_1 Maint_2
City1 Yes n/a
City2 Yes Yes
City3 No
City4 Yes No

I have a table UPS with 2 columns

location Maint_1 Maint_2
City1 Yes n/a
City2 Yes Yes
City3 No
City4 Yes No

I need to calculate percentage (Measure in Power BI) of Cities where no maintenance is done from the 2 Maint_1 & Maint_2 columns, ignoring the "n/a" and null/no values.

In the above table, "%Cities with no maint" = 2/6 = 33.33

numerator = 2 (No + No)

divisor = 6 (Yes + Yes + No + Yes + Yes + No)

Share Improve this question edited Mar 29 at 20:05 Barbaros Özhan 65.5k11 gold badges36 silver badges61 bronze badges asked Mar 29 at 19:58 cghantacghanta 373 bronze badges 1
  • if all values are Yes, the answer should be 0.00 – cghanta Commented Mar 29 at 20:06
Add a comment  | 

1 Answer 1

Reset to default 2

you can select the first column in PQ and unpivot other columns

then create a measure

MEASURE =
COUNTX ( FILTER ( 'Table', 'Table'[Value] = "No" ), 'Table'[Value] )
    / COUNTX (
        FILTER ( 'Table', 'Table'[Value] <> "" && 'Table'[Value] <> "n/a" ),
        'Table'[Value]
    )

本文标签: powerbiCalculate percentage from 2 columnsStack Overflow