Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
EDIT:
Sample data + PBIX here- SampleData-Filtering.zip
(Note: numbers inline below were rough approximations for sake of simplicity - key point is that some were above, some were below the expected value)
ORIGINAL:
Hi folks,
I'm having an issue with something that seems conceptually simple 🙂
I'm trying to create a measure that gives me a "grand total" that is filtered in a particular way.
Data in my table:
OrderNumber = a distinct value
Location = "Chicago 1" or "Chicago 2"
ContactInfo = Yes or blank
NumberOfDailyOrders = A calculated column representing the number of orders in a day.
This report page is filtered on ContactInfo = Yes.
ALL report pages are filtered on NumberOfDailyOrders > 3.
If I go into Data view & manually filter the table, here's what I see.
Just the Location & NumberOfDailyOrders filters = 5000
Location, NumberOfDailyOrders and ContactInfo filters = 128
I'm trying to create a measure for that first value - it's the "grand total" of orders that I'm trying to track. Then I'll use the count of orders with all 3 filters to calculate the % of the grand total that this represents. (Example: 128 / 5000 = 2.56% of the orders are associated with ContactInfo)
Things I've tried for the measure that have not worked, based off reading the DAX docs & looking at a lot of suggestions online:
MySliceTotal = CALCULATE(DISTINCTCOUNT('MyTable'[OrderNumber]), FILTER('MyTable', 'MyTable'[Location] = "Chicago 1"))
MySliceTotal = CALCULATE(DISTINCTCOUNT('MyTable'[OrderNumber]), ALLEXCEPT('MyTable', 'MyTable'[Location], 'MyTable'[NumberOfDailyOrders]))
MySliceTotal = CALCULATE([CountOfOrders], REMOVEFILTERS('MyTable'), VALUES('MyTable'[Location]))
MySliceTotal = CALCULATE([CountOfOrders], REMOVEFILTERS('MyTable'), SUMMARIZE('MyTable', 'MyTable'[NumberOfDailyOrders], 'MyTable'[Location]))
When I tried this in DAX studio, I get the expected result (5000):
VAR TestMyOrderCount = CALCULATE(COUNTROWS('MyTable'), 'MyTable'[Location] = "Chicago 1", 'MyTable'[NumberOfDailyOrders ] > 3)
Any thoughts on what I might be doing wrong here? Even a nudge in the right direction would help. I've been digging into this issue for several hours per day, every day this week, and my brain is fried from all of the searches 🙂
Solved! Go to Solution.
Interesting.
lbendlin-0805 =
CALCULATE (DISTINCTCOUNT('Start'[OrderNumber]),ALLEXCEPT('Start','Start'[Location],'Start'[NumberOfDailyOrders]))
does not work. But
lbendlin-0805 =
CALCULATE (DISTINCTCOUNT('Start'[OrderNumber]),all(),'Start'[Location]="Chicago 1",'Start'[NumberOfDailyOrders]>3)
works. I think it is related to this: Why Power BI totals might seem inaccurate - SQLBI
Here's a compromise:
lbendlin-0805 =
CALCULATE(countrows(VALUES('Start'[OrderNumber])),all('Start'[ContactInfo]),'Start'[NumberOfDailyOrders]>3)
I'm trying to create a measure that gives me a "grand total" that is filtered in a particular way.
How will you make sure that your users will not be confused?
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
Apologies for the poor quality of my post.
I've now provided sample data + a PBIX that has the filtering I described.
MySliceTotal1 =
SUMX (
FILTER (
ADDCOLUMNS (
SUMMARIZECOLUMNS ( 'Start'[Date] ),
"do", CALCULATE ( [CountOfOrders] )
),
[do] > 3
),
[do]
)
but does not take into account any filtering being applied to the visual and/or the page itself.
It doesn't have to - the filter context is taking care of that.
<Having problems posting - think I'm getting flagged as a spammer. 2nd half to this will be in a separate message>
I think one or more of these is true:
Thanks for your patience.
What I'm trying to do is remove a page filter from a set of data.
So when I said "it doesn't take into account any filtering", I meant that your proposed measure doesn't do anything like remove existing filters.
That's one obvious difference that explains why your proposed measure shows different results on the two pages in my sample report.
Had to delete HTML blocks that had the DAX code for MySliceTotal5 and 6.
https:// community.fabric.microsoft.com/t5/Desktop/Removing-Page-level-filter-for-just-1-visualization/m-p/90021
I did additional searches related to my problem, and tried the suggestion in the thread above (this is MySliceTotal5, in the 0804-1615 version of the PBIX added to the zip in the first post) - still not the expected value.
You would need to show your data model, but adding a REMOVEFILTERS on the ContactInfo column to my CALCULATE may be sufficient. But it may also be confusing to your users.
The data model is simple - it's all one table.
Confusing to users - I don't think it will be for 2 reasons
But I DO think that having a hardcoded filter value within the measure itself would be confusing.
I tried modifying the CALCULATE as suggested.
MySliceTotal4 =
SUMX (
FILTER (
ADDCOLUMNS (
SUMMARIZECOLUMNS ( 'Start'[Date] ),
"do", CALCULATE ( [CountOfOrders], REMOVEFILTERS('Start'[ContactInfo]) )
),
[do] > 3
),
[do]
)
That returns 2112 (incorrect).
Drilled into this further in the DAX Query View, removing the SUMX so I could see the table data.
DEFINE
VAR MySliceTotal =
FILTER (
ADDCOLUMNS (
SUMMARIZECOLUMNS ( 'Start'[Date], 'Start'[NumberOfDailyOrders], FILTER('Start', 'Start'[Location] = "Chicago 1") ),
"do", CALCULATE( [CountOfOrders], REMOVEFILTERS('Start'[ContactInfo]))
),
[do] > 3
)
EVALUATE
MySliceTotal ORDER BY [Date] ASC
I included "NumberOfDailyOrders" that I was already calculating, and comparing that to the value in "do". There are many instances where "do" is inexplicably 2x the value of "NumberOfDailyOrders".
Example:
But if that column is showing 2x the value in some cases, I'd expect the result of the SUMX of that column (2112) to be MORE than the expected value (5529). Yet it's less. So there's still some filtering happening that's not clear.
Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.
Sample data in excel file.
Refer to SampleData-Filtering-0805-1430 PBIX for the report with various attempts at these measures, as well as the DAX Query for MySliceTotal that shows the double counting in some scenarios.
Interesting.
lbendlin-0805 =
CALCULATE (DISTINCTCOUNT('Start'[OrderNumber]),ALLEXCEPT('Start','Start'[Location],'Start'[NumberOfDailyOrders]))
does not work. But
lbendlin-0805 =
CALCULATE (DISTINCTCOUNT('Start'[OrderNumber]),all(),'Start'[Location]="Chicago 1",'Start'[NumberOfDailyOrders]>3)
works. I think it is related to this: Why Power BI totals might seem inaccurate - SQLBI
Here's a compromise:
lbendlin-0805 =
CALCULATE(countrows(VALUES('Start'[OrderNumber])),all('Start'[ContactInfo]),'Start'[NumberOfDailyOrders]>3)
Thanks a ton for drilling in. I'm glad I wasn't the only one seeing the weird behavior! 🙂
Thanks for the link. Read through that multiple times today and experimented with some things, and I still don't think I have a handle on what's really happening, but I'll keep looking at it.
I need the measure to not have that hardcoded value & just use the "on all pages" filter, so I'm going to need to use ALLEXCEPT. Hopefully the light bulb goes on soon.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
19 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |