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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tonyclifton
Helper III
Helper III

Count of Measure result

Hello community,

 

I have a Completion Rate Color measure to use it as conditional color formatting for each process.


Example:

2019-10-31 09_18_10-PTM - Power BI Desktop.png
What I want to achieve is that I get the count of each color (e.g. 1x green, 2x yellow, 1x red, 3x grey) so that I can display it in a pie chart visual for example.

Here are the three measures that I created:

CompletedCountMeasure = CALCULATE(COUNT([Job Count]);FILTER('Table';'Table'[Completed] = TRUE()
CompletionRateMeasure =  ROUNDDOWN( DIVIDE([CompletedCountMeasure]; SUM('Table'[Job Count]));2)
CompletionRateColorMeasure = 
var result =  
        SWITCH(TRUE();
           [CompletionRateMeasure] >= 0 &&  [CompletionRateMeasure]   <= 0,70;  "red";
           [CompletionRateMeasure] > 0,70 && [CompletionRateMeasure] <= 0,90; "yellow";
           [CompletionRateMeasure] > 0,90; "green"
         )
return  result


I couldn't find a way to get the count of a measure result. When I try to do it with a calculated column I get a circular dependency error.

 

Is there a way I can get the count with above setup?

 

thank you.

1 ACCEPTED SOLUTION
SeanMcLarty
Advocate I
Advocate I

@tonyclifton  you could create a measure for each colour.  I've used SUMMARIZE() to group the rows by 'Table'[Process].  There is probably a more elegant way to do it with VALUES().

RedCount = 
VAR vRows = SUMMARIZE(
    'Table',
    'Table'[Process],
    "Color", [CompletionRateColorMeasure]
)

RETURN COUNTX(
    FILTER(
        vRows,
        [Color] = "red"
    ),
    1
)
GreenCount = 
VAR vRows = SUMMARIZE(
    'Table',
    'Table'[Process],
    "Color", [CompletionRateColorMeasure]
)

RETURN COUNTX(
    FILTER(
        vRows,
        [Color] = "green"
    ),
    1
)
YellowCount = 
VAR vRows = SUMMARIZE(
    'Table',
    'Table'[Process],
    "Color", [CompletionRateColorMeasure]
)

RETURN COUNTX(
    FILTER(
        vRows,
        [Color] = "yellow"
    ),
    1
)

 

 

View solution in original post

4 REPLIES 4
v-xicai
Community Support
Community Support

Hi @tonyclifton  ,

 

Does that make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

v-xicai
Community Support
Community Support

Hi @tonyclifton ,

 

You may create measures like DAX below.

 

Red_Num= CALCULATE(COUNTX('Table', [CompletionRateColorMeasure] ), FILTER('Table', 'Table'[CompletionRateColorMeasure] = "red"))

 

Yellow_Num= CALCULATE(COUNTX('Table', [CompletionRateColorMeasure] ), FILTER('Table', 'Table'[CompletionRateColorMeasure] = "yellow"))

 

Green_Num= CALCULATE(COUNTX('Table', [CompletionRateColorMeasure] ), FILTER('Table', 'Table'[CompletionRateColorMeasure] = "green"))

 

Best Regards,

Amy

 

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

Ashish_Mathur
Super User
Super User

Hi,

Share the link from where I can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
SeanMcLarty
Advocate I
Advocate I

@tonyclifton  you could create a measure for each colour.  I've used SUMMARIZE() to group the rows by 'Table'[Process].  There is probably a more elegant way to do it with VALUES().

RedCount = 
VAR vRows = SUMMARIZE(
    'Table',
    'Table'[Process],
    "Color", [CompletionRateColorMeasure]
)

RETURN COUNTX(
    FILTER(
        vRows,
        [Color] = "red"
    ),
    1
)
GreenCount = 
VAR vRows = SUMMARIZE(
    'Table',
    'Table'[Process],
    "Color", [CompletionRateColorMeasure]
)

RETURN COUNTX(
    FILTER(
        vRows,
        [Color] = "green"
    ),
    1
)
YellowCount = 
VAR vRows = SUMMARIZE(
    'Table',
    'Table'[Process],
    "Color", [CompletionRateColorMeasure]
)

RETURN COUNTX(
    FILTER(
        vRows,
        [Color] = "yellow"
    ),
    1
)

 

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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