Forum Discussion

timgiefer's avatar
timgiefer
New Member
8 years ago
Solved

Count value in column measure

Hi everyone!

 

I'm new to Microsoft Power Bi but there is the thing I want to do:

 

I've got a column called "cutting" with 0 (machine isn't working) and 1 (machine is working).

I want to create a measure called "UT" where the amount of rows with "cutting" = 1 is divided by the total amount of columns in the table 'Tabelle1'. The DAX formula is the following:

 

UT = CALCULATE(COUNT('Tabelle1'[cutting])/COUNTROWS('Tabelle1'); 'Tabelle1'[cutting] = 1)

When I try to display the measure on my dashboard, the field is blank.

 

I have already looked at different forum posts similar to my problem, but nothing seems to work.

 

 

Can anyone help?

 

 

Thanks

 

 

Tim

 

 

 

  • timgiefer

     

    You should specify the context into entire table in your calculation formula. 

     

    UT =
    CALCULATE (
        COUNT ( 'Tabelle1'[cutting] ),
        FILTER ( ALL ( 'Tabelle1' ), 'Tabelle1'[cutting] = 1 )
    )
        / COUNTROWS ( 'Tabelle1' )

    Regards,

2 Replies

  • CahabaData's avatar
    CahabaData
    Memorable Member

    please clarify what is meant by: "...the total amount of columns in table.....

     

    how many columns and what are their names - a small sampling of the data set would help

  • v-sihou-msft's avatar
    v-sihou-msft
    Microsoft Employee

    timgiefer

     

    You should specify the context into entire table in your calculation formula. 

     

    UT =
    CALCULATE (
        COUNT ( 'Tabelle1'[cutting] ),
        FILTER ( ALL ( 'Tabelle1' ), 'Tabelle1'[cutting] = 1 )
    )
        / COUNTROWS ( 'Tabelle1' )

    Regards,