Forum Discussion

mcomsto's avatar
mcomsto
Helper I
6 years ago
Solved

Counting rows based on difference between two filtered measures

Hi,

 

I have been struggling with this issue for some time.  I am trying to count the rows in a table visualization based on the difference between to calculated measures.  I have attached a pbix file with mock data. Any help would be greatly appreiciated. 

 

https://www.dropbox.com/s/gbfb8nmwyp2bkrp/mockupforcountxissue.pbix?dl=0

 

 

  • mcomsto here are the measure to count

     

    Q1 Above Zero = COUNTX ( VALUES ( Sheet1[Customer] ), IF ( [Comp Q1 Form Score Diff] > 0, 1 ) )
    
    Q1 Equals Zero = COUNTX ( VALUES ( Sheet1[Customer] ), IF ( [Comp Q1 Form Score Diff] = 0, 1 ) )
    
    Q1 Less Zero = COUNTX ( VALUES ( Sheet1[Customer] ), IF ( [Comp Q1 Form Score Diff] < 0, 1 ) )

     

    Would appreciate Kudos 🙂 if my solution helped. 

2 Replies

  • mcomsto here are the measure to count

     

    Q1 Above Zero = COUNTX ( VALUES ( Sheet1[Customer] ), IF ( [Comp Q1 Form Score Diff] > 0, 1 ) )
    
    Q1 Equals Zero = COUNTX ( VALUES ( Sheet1[Customer] ), IF ( [Comp Q1 Form Score Diff] = 0, 1 ) )
    
    Q1 Less Zero = COUNTX ( VALUES ( Sheet1[Customer] ), IF ( [Comp Q1 Form Score Diff] < 0, 1 ) )

     

    Would appreciate Kudos 🙂 if my solution helped. 

  • sturlaws's avatar
    sturlaws
    Resident Rockstar

    Hi mcomsto,

    this is one option:

    Q1 Equals Zero =
    COUNTROWS (
        FILTER (
            ADDCOLUMNS ( VALUES ( Sheet1[Customer] ); "tmp"; [Comp Q1 Form Score Diff] );
            [tmp] = 0
        )
    )

     

    Cheers,
    Sturla