Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Create Calculated Column with Conditions

Good morning, I hope you can help me what I want to do in Power Bi in this   If a worker has the number 15 twice (that is, the name is repeated), how can I make a column place the number 2? ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    I think you can try this code to create a calculated column.

    Calculated Column with Conditions =
    VAR _COUNT_15 =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( ALLEXCEPT ( 'Table', 'Table'[NOMBRES] ), 'Table'[LIQ] = 15 )
        )
    VAR _COUNT_Lessthan_15 =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( ALLEXCEPT ( 'Table', 'Table'[NOMBRES] ), 'Table'[LIQ] < 15 )
        )
    RETURN
        IF ( _COUNT_Lessthan_15 = 1, 1, _COUNT_15 )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.