Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
JacobCoops
Frequent Visitor

Count If measure

Hello

 

I am trying to create a measure that returns the percentage of customers with 3 or more logins. My dataset is a list of CustomerIDs and timestamps (logins) where one row equals one login. If i were to do this in Excel i would use the CountIf function on a pivoted dataset (to group the customer IDs):

 

Excel.jpg

 

 

 

 

 

 

 

 

 

 

My dataset look like this:

PBI Data.jpg

 

 

 

 

 

 

 

 

 

I have tried creating a calcuated coloumn that correctly counts the total number of logins pr. CustomerID (KundeID in the picture). The issue is, however, that the calculated coloumn does not respond to the date-slicers in the report. The users therefore cant choose to only evaluate 2020 data, for instance, which is why i figured it had to be a measure.

Based on the picture above the measure would return the number 2 since Customer ID 96090 is represented 5 times and ID 96045 is represented  4 times and the remaining two is shown 1 time each.

 

My current attempts have led me to this: 

PBI Example.jpg 

 

 

 

 

 

 

 

 

 

 

 

 

What i would want the measure to do is to summarize the coloumn "Countrows 3".

 

As a bonus question i would like to know, if it is possible to change the threshold "3" to a dynamic value that users can change in a slicer?

 

I am a complete novice at PBI and DAX so there might be something obvious that i am missing so i appreciate any pointers. 

Thank you for your time

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Measure = 

  VAR __Table = 

    FILTER(

      SUMMARIZE(

        'Table',

        [KundeID],

        "__Count", COUNTROWS('Table')

      ),

     [__Count] > 3

  )

RETURN

  COUNTROWS(__Table)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Measure = 

  VAR __Table = 

    FILTER(

      SUMMARIZE(

        'Table',

        [KundeID],

        "__Count", COUNTROWS('Table')

      ),

     [__Count] > 3

  )

RETURN

  COUNTROWS(__Table)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg

 

This is friggin amazing. Thank you very much!

Cool, glad it worked for you! 🙂


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.