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
Anonymous
Not applicable

Counting Measures

I'm trying to count the measures

 Company ACompany BCompany CCompany D
PRODUCT W$100$120$140$150
PRODUCT X$200$180$160$140
PRODUCT Y$150$200$160$130
PRODUCT Z$160$120$180

$140

 

If company  has lower price for the product it will sell. so I ranked them using the formula, where for product W, Company A-rank1, Company B-rank2, Company C-rank3, Company D-rank4. where rank 1 company gets to sell that product.

so i'm using what-if scneario variable to apply discounts to Company A such as applying 5% or 10% to all Company A products and trying to see how many products Company A will get to be rank1 or rank2 and etc.

so i used measure to apply discounts  from what-if scenario variables. and got the new ranks as well.

 

now my problem is counting how many each company has rank 1s.

counting in Powerbi shows that it can count columns not measures.

 

i tried setting calculated columns = measure but columns are not dynamic as i change the discount variable.

 

Need help

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create measures like this.

__Current_value = MAX(Sheet6[Price])
__Rank = 
RANKX(
    FILTER(
        ALL(Sheet6),
        Sheet6[Product] = MAX(Sheet6[Product])
    ),
    [__Current_value],
     , ASC, Dense
)
__Count = 
COUNTX(
    FILTER(
        ALL(Sheet6),
        [__Rank] = 1 && Sheet6[Company] = MAX(Sheet6[Company])
    ),
    [__Rank]
)

v-lionel-msft_0-1595842271031.png

 

Best regards,
Lionel Chen

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

 

View solution in original post

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create measures like this.

__Current_value = MAX(Sheet6[Price])
__Rank = 
RANKX(
    FILTER(
        ALL(Sheet6),
        Sheet6[Product] = MAX(Sheet6[Product])
    ),
    [__Current_value],
     , ASC, Dense
)
__Count = 
COUNTX(
    FILTER(
        ALL(Sheet6),
        [__Rank] = 1 && Sheet6[Company] = MAX(Sheet6[Company])
    ),
    [__Rank]
)

v-lionel-msft_0-1595842271031.png

 

Best regards,
Lionel Chen

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,

You can count the return return result of measures by using CALCULATE(), COUNTX(), COUNTAX().


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.



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.