cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SBuri Resolver II
Resolver II

If >2 Selections, do not display the graph, else display the graph

Hey,

 

 

I'm trying to make a measure that will not display a sum on a graph if certain criteria are met. However, instead of breaking it goes ahead and displays the sum regardless of whether or not the if statement conditions are met. How can I make a measure that will not display aggregated counts if certain criteria are met?

 

Ex - 

Input: 24, 52, 37

Measure: If(Count(Input)>2, "Please maintain 1-2 inputs", Sum(Input)

Desired Output: "Please maintain 1-2 inputs"

Actual Output: Sum(Input)

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: If >2 Selections, do not display the graph, else display the graph

HI @SBuri,

 

Greg's suggestion seems well, I share the sample formula here.

Measure =
IF (
    COUNTROWS ( ALLSELECTED ( Table[Input] ) ) > 2,
    "Please maintain 1-2 inputs",
    SUMX ( ALLSELECTED ( Table[Input] ), [Input] )
)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

3 REPLIES 3
Super User IV
Super User IV

Re: If >2 Selections, do not display the graph, else display the graph

Might have better luck with COUNTROWS instead of COUNT if it is a table. 

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


---------------------------------------

Not the Power BI thought police...

I have NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Community Support
Community Support

Re: If >2 Selections, do not display the graph, else display the graph

HI @SBuri,

 

Greg's suggestion seems well, I share the sample formula here.

Measure =
IF (
    COUNTROWS ( ALLSELECTED ( Table[Input] ) ) > 2,
    "Please maintain 1-2 inputs",
    SUMX ( ALLSELECTED ( Table[Input] ), [Input] )
)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

SBuri Resolver II
Resolver II

Re: If >2 Selections, do not display the graph, else display the graph

Thank you both!!

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors