Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello,
I want to get the number of stores by each year and by each type of stores based on the sales column.
If it is > 0, I should be counted.
This should be the output result:
I am using DISTINCCOUNT and it works well at store level, but the aggregation at type of stores and total is incorrect because it counts stores even with zero sales.
Below the sample dataset.
Category | Zone | Store | Extention | Type of Store | Units | Year |
Category5 | rear | 3254 | 136,6 | E | 0 | 2022 |
Category5 | rear | 2052 | 102,06 | C | 217 | 2022 |
Category5 | rear | 4534 | 168,07 | E | 0 | 2022 |
Category5 | rear | 2067 | 117 | C | 174 | 2022 |
Category5 | rear | 7866 | 116 | C | 226 | 2022 |
Category5 | rear | 25 | 0 | B | 0 | 2022 |
Category5 | rear | 65 | 0 | D | 0 | 2022 |
Category4 | rear | 6756 | 118,92 | A | 639 | 2022 |
Category4 | rear | 11 | 0 | B | 0 | 2022 |
Category4 | rear | 112 | 133,67 | D | 0 | 2022 |
Category4 | entrance | 3254 | 279,96 | E | 0 | 2022 |
Category4 | entrance | 2052 | 351,11 | C | 313 | 2022 |
Category4 | entrance | 4534 | 369,54 | E | 0 | 2022 |
Category4 | entrance | 2067 | 322 | C | 386 | 2022 |
Category4 | entrance | 7866 | 439 | C | 338 | 2022 |
Category4 | entrance | 25 | 313,48 | B | 503 | 2022 |
Category4 | entrance | 65 | 192,86 | D | 220 | 2022 |
Category3 | entrance | 6756 | 355,63 | A | 911 | 2022 |
Category3 | entrance | 11 | 337,65 | B | 838 | 2022 |
Category3 | entrance | 112 | 281,71 | D | 225 | 2022 |
Category3 | rear | 3254 | 136,6 | E | 0 | 2022 |
Category3 | rear | 2052 | 102,06 | C | 196 | 2022 |
Category3 | rear | 4534 | 168,07 | E | 0 | 2022 |
Category3 | rear | 2067 | 117 | C | 136 | 2022 |
Category3 | rear | 7866 | 116 | C | 132 | 2022 |
Category3 | rear | 25 | 0 | B | 7 | 2022 |
Category2 | rear | 65 | 0 | D | 0 | 2022 |
Category2 | rear | 6756 | 118,92 | A | 313 | 2022 |
Category2 | rear | 11 | 0 | B | 0 | 2022 |
Category2 | rear | 112 | 133,67 | D | 0 | 2022 |
Category2 | entrance | 3254 | 279,96 | E | 0 | 2022 |
Category2 | entrance | 2052 | 351,11 | C | 489 | 2022 |
Category2 | entrance | 4534 | 369,54 | E | 0 | 2022 |
Category2 | entrance | 2067 | 322 | C | 545 | 2022 |
Category2 | entrance | 7866 | 439 | C | 699 | 2022 |
Category2 | entrance | 25 | 313,48 | B | 1319 | 2022 |
Category2 | entrance | 65 | 192,86 | D | 346 | 2022 |
Category1 | entrance | 6756 | 355,63 | A | 1717 | 2022 |
Category1 | entrance | 11 | 337,65 | B | 1860 | 2022 |
Category1 | entrance | 112 | 281,71 | D | 366 | 2022 |
Category5 | rear | 3254 | 136,6 | E | 120 | 2021 |
Category5 | rear | 2052 | 102,06 | C | 0 | 2021 |
Category5 | rear | 4534 | 168,07 | E | 541 | 2021 |
Category5 | rear | 2067 | 117 | C | 186 | 2021 |
Category5 | rear | 7866 | 116 | C | 580 | 2021 |
Category5 | rear | 25 | 0 | B | 915 | 2021 |
Category5 | rear | 65 | 0 | D | 28 | 2021 |
Category4 | rear | 6756 | 118,92 | A | 134 | 2021 |
Category4 | rear | 11 | 0 | B | 0 | 2021 |
Category4 | rear | 112 | 133,67 | D | 171 | 2021 |
Category4 | entrance | 3254 | 279,96 | E | 282 | 2021 |
Category4 | entrance | 2052 | 351,11 | C | 0 | 2021 |
Category4 | entrance | 4534 | 369,54 | E | 587 | 2021 |
Category4 | entrance | 2067 | 322 | C | 772 | 2021 |
Category4 | entrance | 7866 | 439 | C | 82 | 2021 |
Category4 | entrance | 25 | 313,48 | B | 430 | 2021 |
Category4 | entrance | 65 | 192,86 | D | 778 | 2021 |
Category3 | entrance | 6756 | 355,63 | A | 699 | 2021 |
Category3 | entrance | 11 | 337,65 | B | 0 | 2021 |
Category3 | entrance | 112 | 281,71 | D | 614 | 2021 |
Category3 | rear | 3254 | 136,6 | E | 498 | 2021 |
Category3 | rear | 2052 | 102,06 | C | 0 | 2021 |
Category3 | rear | 4534 | 168,07 | E | 875 | 2021 |
Category3 | rear | 2067 | 117 | C | 278 | 2021 |
Category3 | rear | 7866 | 116 | C | 951 | 2021 |
Category3 | rear | 25 | 0 | B | 484 | 2021 |
Category2 | rear | 65 | 0 | D | 119 | 2021 |
Category2 | rear | 6756 | 118,92 | A | 247 | 2021 |
Category2 | rear | 11 | 0 | B | 0 | 2021 |
Category2 | rear | 112 | 133,67 | D | 942 | 2021 |
Category2 | entrance | 3254 | 279,96 | E | 910 | 2021 |
Category2 | entrance | 2052 | 351,11 | C | 0 | 2021 |
Category2 | entrance | 4534 | 369,54 | E | 41 | 2021 |
Category2 | entrance | 2067 | 322 | C | 44 | 2021 |
Category2 | entrance | 7866 | 439 | C | 737 | 2021 |
Category2 | entrance | 25 | 313,48 | B | 658 | 2021 |
Category2 | entrance | 65 | 192,86 | D | 196 | 2021 |
Category1 | entrance | 6756 | 355,63 | A | 730 | 2021 |
Category1 | entrance | 11 | 337,65 | B | 0 | 2021 |
Category1 | entrance | 112 | 281,71 | D | 181 | 2021 |
It should also be considered that when I slice by zone type some stores values might become zero as well.
Your help will be much appreciated.
Solved! Go to Solution.
I think the below should work as a measure
Num stores = CALCULATE( DISTINCTCOUNT( Stores[Store]), Stores[Units] > 0)
I think the below should work as a measure
Num stores = CALCULATE( DISTINCTCOUNT( Stores[Store]), Stores[Units] > 0)
Hello, this is not working because in the part in the part "Stores[Units]" I need to input another measure or a calculation because I need to filter by the sales for each year.
Year cannot go into the matrix column headers in order to filter as I have many other values.
I need to create two separate measures for each year and inside them filter for each year sales accordingly.
Thanks!