Forum Discussion

maximik's avatar
maximik
Frequent Visitor
2 years ago
Solved

How to count rows based on two criteria?

Hi all, I am building my first PowerBI project and so far it works great. Unfortunately, I know stumbled on a big problem and I am unsure on how to solve it.   I have a gigantic table, it looks s...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi maximik 

    1.You can create a slicer table

    Slicer = {"Counts","Counts>0"}

    2.Then create a measure

    Counts =
    IF (
        OR (
            ISFILTERED ( Slicer[Value] ) = FALSE (),
            SELECTEDVALUE ( Slicer[Value] ) = "Counts"
        ),
        CALCULATE ( COUNTA ( 'Table'[VM/Instance in that scale Set] ) ),
        IF (
            SELECTEDVALUE ( Slicer[Value] ) = "Counts>0",
            CALCULATE (
                COUNTA ( 'Table'[VM/Instance in that scale Set] ),
                FILTER ( 'Table', [Max CPU performance] > 0 )
            )
        )
    )
    

    3.Then create a column visual, put the time to the x-axis, and put the measure to y-axis, then put the virtual to legend, and put the value of slicer table to a slicer.

    Output

     

    Best Regards!

    Yolo Zhu

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