Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Calculated % measure

Hello, 

 

I have problems creating a measure, i want to show on a line chart the percentage of "orders on time" (1).

My power bi table looks like the first one with orders and itmes, and when I make this measure the result is 63%, but it really should be 60% , because it depens on the number of orders, not the number of itmes in the order.

 

My measure is sum(time)/count(order) = 7/11, and should be 3/5

 

How can I make the measure, without loosing the item column?

Please I need Help

  • Hi Anonymous

     

    You may create measure as below:

    Measure =
    COUNTROWS ( SUMMARIZE ( FILTER ( Table1, Table1[Time] = 1 ), Table1[Order] ) )
        / DISTINCTCOUNT ( Table1[Order] )

     

    Regards,

    Cherie

2 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Anonymous

     

    Try this one

     

    Measure =
    VAR orderswithTime1 =
        COUNTROWS (
            FILTER ( VALUES ( Table1[Order] ), CALCULATE ( SUM ( Table1[Time] ) ) > 0 )
        )
    VAR TotalOrders =
        COUNTROWS ( VALUES ( Table1[Order] ) )
    RETURN
        DIVIDE ( orderswithTime1, TotalOrders )
  • v-cherch-msft's avatar
    v-cherch-msft
    Microsoft Employee

    Hi Anonymous

     

    You may create measure as below:

    Measure =
    COUNTROWS ( SUMMARIZE ( FILTER ( Table1, Table1[Time] = 1 ), Table1[Order] ) )
        / DISTINCTCOUNT ( Table1[Order] )

     

    Regards,

    Cherie