Power BI Exchange

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
Expand all | Collapse all

Calculate(Countrows( Not working))

  • 1.  Calculate(Countrows( Not working))

    Bronze Contributor
    Posted 13 days ago
    I have a DAX formula below but it isn't updating the count. When i do a charrt of the data i am getting double what the formula below is giving me as a result. I tried to add a new measure with the same formula and got the same result. Any help is appreciated.

    Calculate( COUNTROWS('Table 1'),
    'Table 1'[Preventable or Not] = "Preventable")


    ------------------------------
    Mike Tienken
    Operations Analyst
    Tualatin
    ------------------------------
    Conference-PBI_200x200


  • 2.  RE: Calculate(Countrows( Not working))

    Bronze Contributor
    Posted 13 days ago
    Hi @Mike Tienken,

    try:
    =
    CALCULATE (
        COUNTROWS ( 'Table 1' ),
        FILTER ( 'Table 1', 'Table 1'[Preventable or Not] = "Preventable" )
    )

    There is a big difference between using FILTER or not within CALCULATE. I recommend this article from SQLBI, they describe in detail what happens in each case (+ a few more cases): https://www.sqlbi.com/articles/filter-arguments-in-calculate/
    I assume that in your chart, you're using 2 data fields, so it will return the result for "preventable" for both of them. By using FILTER, you can avoid this.

    Hope it helps.

    Best,
    Chris

    ------------------------------
    Christoph Spieles
    Senior BI Developer & Analyst

    Berlin Power BI User Group Meetup Organizer
    https://www.meetup.com/de-DE/Berlin-Power-BI-User-Group/
    ------------------------------

    Conference-PBI_200x200