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

Allow Users to Override Measure Logic that Filters the Table

I have a table which matches companies based on similarity. It is constructed so that for each company, it will match against every other company, and give those matches a rank. eg.

Let's call this table 'Company Comparison'

CompanyMatched CompanyRank

A

C1

A

B2

A

D3

B

D1

B

C2

etc.

  


I then have a number of measures that, when the data is filtered on 'Company' eg. to Company A, will calculate the metric for the company matched with A at Rank 1 - so in the example above would calculate the metric for company C. The measures use the format:

CC Metric = CALCULATE([CompetitorMetric],'Company Comparison'[Rank] = 1)

What I want to do is create a slicer or similar where a business user can override this logic at will. So instead of always showing the metrics for Company C compared to A (because this is it's top match) the user could use a dropdown to say they thought A's closest competitor was B and they'd like to see the results for that instead. Ideally they could even select multiple and the competitor metrics would be for the data associated with all of those selected companies.

I'm stuck on how to acheive this. If I create a slicer on Matched Company in 'Company Comparison', the measures just won't work because the user might select a company that isn't Rank 1 and so the measure uses it's 'Company Comparison'[Rank] = 1 filter and finds no results.
 
If I try to change the measure so it looks for the highest rank remaining, instead of always rank '1' eg.
CC Metric = CALCULATE(VALUES('Company Comparison'[Competitor Metric]),FILTER('Company Comparison', 'Company Comparison'[Rank] = [Top Available Rank]))
this won't cover the multiple selection option.

Does anyone have ideas for how I might go about this?

1 ACCEPTED SOLUTION

@Anonymous - The short form is:

 

Measure =
  SWITCH(SELECTEDVALUE('DisconnectedTable'[Column]),
    "Option 1", <calculation one way>,
    "Option 2", <calculation a different way>
  )

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

@Anonymous - Seems like an implementation of the Disconnected Table Trick. Basically, use a disconnected table as a slicer and then based on the selection in that slicer, perform calculations differently.

 

Here is one example - Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick/ba-p/279563


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks @Greg_Deckler , I'll have a read through 🙂

@Anonymous - The short form is:

 

Measure =
  SWITCH(SELECTEDVALUE('DisconnectedTable'[Column]),
    "Option 1", <calculation one way>,
    "Option 2", <calculation a different way>
  )

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User
Anonymous
Not applicable

Thanks @amitchandak, the rank in this case is static (calculated outside powerbi and then brought in). So I guess what I'm trying to get at is if I have measures that filter on a column like that, but I'd also like a user to be able to override that and instead choose which rows they personally want to filter on, how do I code that into a measure? That it should let the user override it's filter if they want to?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.