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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
WorkHard
Helper V
Helper V

DAX to Filter an existing measure

Consider the following table with tasks per user.

UsernameTask NameStatus
User1Task1Completed
User1Task2Incomplete
User1Task3Completed
User2Task1Completed
User2Task2Completed
User2Task3Completed

I have a measure that calculates the percentage of Tasks completed per user that looks like this:

 

 

Measure Percentage Completion Per User =

var TasksCompleted =
SUMX(
VALUES('Table'[Username]),
CALCULATE(DISTINCTCOUNT('Table'[Task Name]),'Table'[Status]="Completed"))
)
var TasksIncomplete = 
SUMX(
VALUES('Table'[Username]),
CALCULATE(DISTINCTCOUNT('Table'[Task Name]),'Table'[Status]="Incomplete"))
)
RETURN
TasksCompleted/TasksIncomplete+TasksCompleted

 

 

The result is:

User1: 66.6%

User2: 100%

This all works well until I attempt to then use the above measure to create percentage brackets.

Say, how many users have 80%-100% completion, how many have 60%-80% completion, etc.


I tried to create a measure for each bracket like this but it doesn't return the correct result:

 

 

CompletionBracket%80-100 = calculate(DISTINCTCOUNT('Table'[Username]),filter('Table',[Measure Percentage Completion Per User]>=0.8 && [Measure Percentage Completion Per User]<=1))

 

 

 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @WorkHard 

For "Percentage Completion Per User" try this:

 

Percentage Completion Per User = 
VAR _User =
    COUNTROWS ( 'Table' )
VAR _Complete =
    CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Status] = "Completed" )
RETURN
    _Complete / _User

 

 

and for "CompletionBracket%80-100" try this:

 

CompletionBracket%80-100 = 
VAR _A =
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[Username],
            "PerCom", [Percentage Completion Per User]
        ),
        [Percentage Completion Per User] >= 0.8
            && [Percentage Completion Per User] <= 1
    )
RETURN
    COUNTAX ( _A, [Username] )

 

 

the output:

VahidDM_0-1635890521238.png

 

 

 

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

Appreciate your Kudos!!

 

View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @WorkHard 

For "Percentage Completion Per User" try this:

 

Percentage Completion Per User = 
VAR _User =
    COUNTROWS ( 'Table' )
VAR _Complete =
    CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Status] = "Completed" )
RETURN
    _Complete / _User

 

 

and for "CompletionBracket%80-100" try this:

 

CompletionBracket%80-100 = 
VAR _A =
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[Username],
            "PerCom", [Percentage Completion Per User]
        ),
        [Percentage Completion Per User] >= 0.8
            && [Percentage Completion Per User] <= 1
    )
RETURN
    COUNTAX ( _A, [Username] )

 

 

the output:

VahidDM_0-1635890521238.png

 

 

 

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

Appreciate your Kudos!!

 

Greg_Deckler
Super User
Super User

@WorkHard You need to get your users and ADDCOLUMNS your measure in a table variable. Then you can filter that table variable and COUNTROWS on in it. Like:

Measure 80-100 = 
  VAR __Table = 
    ADDCOLUMNS(
      DISTINCT('Table'[Username]),
      "__Measure",[Measure Percentage Completion Per User]
    )
RETURN
  COUNTROWS(FILTER(__Table,[__Measure]>=.8 && [__Measure]<=1))


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.