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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MacyMolly
Helper II
Helper II

Distinct Count and count the ones with an average Score of >= 90%

MacyMolly_2-1622506220708.png

Hi All, 
I'm new to powerbi. I'm trying to create a measure that will only count with Score(% Score) average of >=90% by ID. A distinct value on column "ID". Kindly refer to the attached image. Your help is greatly appreciated.

1 ACCEPTED SOLUTION

Hi @MacyMolly  try this:

NewMeasure =
VAR _distinctCount =
    DISTINCTCOUNT ( 'Table'[ID] ) //Count how many ids
VAR _summarizeTable =
    SUMMARIZECOLUMNS (
        'Table'[ID],
        'Table',
        "Average",
            IF ( AVERAGE ( 'Table'[%Score] ) >= .9, 1, 0 ) //if equal to or greater than .9 give it a 1
    )
VAR _passingCount =
    SUMX ( _summarizeTable, [Average] )
VAR _calc =
    DIVIDE ( _passingCount, _distinctCount ) //Sum the average column from the table above and divide it by the total of ids
RETURN
    _calc

 

Nathaniel_C_0-1622592689787.png

and if you just want the passing count, return _passingCount instead of _calc
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
Nathaniel_C
Super User
Super User

Hi @MacyMolly , and if you use essentially the same measure, but just return the _calc, you will have the averages.

 

myMeasureAverage = 
VAR _curID =
    MAX ( 'Table'[ID] )
VAR _calc =
    CALCULATE (
        AVERAGE ( 'Table'[%Score] ),
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[ID] ), MAX ( 'Table'[ID] ) = _curID )
    )
RETURN
    _calc

 

Bonus! 

Nathaniel_C_0-1622510665537.png

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Nathaniel_C, I'm sorry. I think I wasn't able to express myself very well. Well, I only want to create a measure that will count of all the distinct ID that able to achieved an average score of >= 0.90. I have a filter that can select multi weeks.
1. distinctcount ( ID)
2. only count each distinct ID if they passed the score of >= .90
3. Get the passing rate: total count of distinct ID who passed divided by the distinctcount(ID)

Hi @MacyMolly  try this:

NewMeasure =
VAR _distinctCount =
    DISTINCTCOUNT ( 'Table'[ID] ) //Count how many ids
VAR _summarizeTable =
    SUMMARIZECOLUMNS (
        'Table'[ID],
        'Table',
        "Average",
            IF ( AVERAGE ( 'Table'[%Score] ) >= .9, 1, 0 ) //if equal to or greater than .9 give it a 1
    )
VAR _passingCount =
    SUMX ( _summarizeTable, [Average] )
VAR _calc =
    DIVIDE ( _passingCount, _distinctCount ) //Sum the average column from the table above and divide it by the total of ids
RETURN
    _calc

 

Nathaniel_C_0-1622592689787.png

and if you just want the passing count, return _passingCount instead of _calc
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




You Rock! Thank you @Nathaniel_C

Hi @MacyMolly , you are welcome!

Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Nathaniel_C
Super User
Super User

Hi @MacyMolly ,

 

 

 

myMeasurecount =
VAR _curID =
    MAX ( 'Table'[ID] )
VAR _calc =
    CALCULATE (
        AVERAGE ( 'Table'[%Score] ),
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[ID] ), MAX ( 'Table'[ID] ) = _curID )
    )
RETURN
    IF ( _calc >= .90, 1, 0 )

Capture6.PNG

 

 Try this.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.