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.
Hope I can describe this problem correctly! I have 2 tables, not joined to each other:
FACT Table
Location | Category A | Category B | Value |
1 | A | Z | 51 |
1 | B | X | 100 |
2 | A | Z | 56 |
2 | C | Y | 105 |
3 | B | W | 61 |
3 | D | Q | 110 |
4 | A | Q | 52 |
4 | A | Z | 102 |
Min/Max Table:
Min | Max |
150 | 160 |
160 | 170 |
170 | 180 |
...continuing pattern |
...with each table having many, many more rows. What I am trying to do is come up with a DAX formula that will allow me to build a table visual with the following output:
Min | Max | Count of Locations with Sum of [Values] between min/max |
150 | 160 | 2 |
160 | 170 | 1 |
170 | 180 | 1 |
The DAX I have tried for the "Count of Locations..." column is this:
Count of Locations =
var minV = MIN(GroupsTbl[Min])
var maxV = MAX(GroupsTbl[Max])
var sumValues = SUM(FactTbl[Value])
var locCount = CALCULATE(DISTINCTCOUNT(FactTbl[Location]),FILTER(FactTbl,sumValues>=minV),FILTER(FactTbl,sumValues<maxV))
return locCount
...but this returns an output that is not paritioned by the Location column. Something like this using the example above:
Min | Max | Count of Locations with Sum of Values between min/max |
640 | 650 | 4 |
This would be pretty easy to solve by pre-aggregating the table to remove the 2 "Category" columns - but I need to be able to filter with slicers on those columns, and have the count of locations (and sum of values) update based on the selected values from the slicers.
I hope this is enough explanation - apologies if not! Happy to provide more info/answer questions! 🙂
Any help would be greatly appreciated. Thanks -Joe
Solved! Go to Solution.
Hey Joe,
This formula should provide the desired output based on the details required:
Count of Locations = VAR MinValue = MIN(GroupsTbl[Min]) VAR MaxValue = MAX(GroupsTbl[Max]) RETURN COUNTROWS( FILTER( SUMMARIZE( FactTbl, FactTbl[Location], "LocationSum", SUM(FactTbl[Value]) ), [LocationSum] >= MinValue && [LocationSum] < MaxValue ) )
SUMMARIZE:
FILTER:
COUNTROWS:
Thanks to both for the help!!
Hi @JoeCochran please try this
Hey Joe,
This formula should provide the desired output based on the details required:
Count of Locations = VAR MinValue = MIN(GroupsTbl[Min]) VAR MaxValue = MAX(GroupsTbl[Max]) RETURN COUNTROWS( FILTER( SUMMARIZE( FactTbl, FactTbl[Location], "LocationSum", SUM(FactTbl[Value]) ), [LocationSum] >= MinValue && [LocationSum] < MaxValue ) )
SUMMARIZE:
FILTER:
COUNTROWS:
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
10 | |
7 | |
6 | |
6 |
User | Count |
---|---|
30 | |
11 | |
11 | |
10 | |
6 |