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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mdannemiller
Frequent Visitor

Using non-explicit Filters in Measures?

I need to compare a calculated value to the same calculated value where 2 fields are matched.

 

for example, if I'm looking at bus fare I'd have a table like this:

 

[Fare paid], [Route], [City], [State], [riderID] 

 

So let's say that for route 1, the sum of all the fares paid is $10,000.  I can use a simple measure Calculate(SUM([Fare paid]) to find it.  However, I then need to compare that total to the fares paid for all routes in the same city and state.  So.  Let's say for Austin, TX route 1, the total is 100,000.

 

I'm having huge issues making this work.  if I use CALCULATE(SUM([fare paid], ALLEXCEPT('Bus Fare Fact', [City], [State])) I get the sum for everything.  I'd want to do a filter like this CALCULATE(SUM([Fare paid]), [City] = [City], [State] = [State])) But that obviously doesn't work.  Is there a way that I can access that value with a measure?  I tried with a calculated column where I know I can reference the column, but, because I'm using this calculation multiple times, it was taking 5-10 minutes to render the page, so I need to use a measure for performance issues.  

 

I also can't use a separate table to do the calculations (at least a non-memory table), because I have a rider table with demographic information about the rider that is used in filters in this table.

2 REPLIES 2
v-danhe-msft
Employee
Employee

Hi @mdannemiller,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-danhe-msft
Employee
Employee

Hi @mdannemiller,

Based on my test, you could refer to below steps:

Sample data:

1.PNG

Create a measure:

Filter value = CALCULATE(SUM(Table1[Fare paid]),FILTER(ALL('Table1'),'Table1'[State]=MAX('Table1'[State])), FILTER(ALL('Table1'),'Table1'[City]=MAX('Table1'[City])))

Result:

1.PNG

If I misunderstand you, could you please share some sample data and post your desired result if possible?

Also, you could download my pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.