Forum Discussion
Measure counting rows, grouped by two different colums
- 11 months ago
Hi BieBel
DISTINCTCOUNT ('table'[ORDER ID] should be okay if the ID doesn't repeat in other region or months. However, if the same ORDER ID can be re-used, try
COUNTROWS ( SUMMARIZE ( -- Create a table of distinct combinations of the following columns: 'table'[ORDER ID], -- Unique order identifier 'table'[SALES_REGION], -- Region where the order was made 'table'[MONTH_OF_ORDER_DATE] -- Month of the order date ) )
Hi BieBel
You can handle this easily with a measure. Just write:
Orders Count = DISTINCTCOUNT ( 'Orders'[ORDER_ID] )
This way you’ll always get the unique count of orders. When you drop SALES_REGION and MONTH_OF_ORDER_DATE into your visual, Power BI automatically applies the filter context so the measure shows the right number for each region and month. If every order ID is unique in your table you could also use COUNTROWS ( 'Orders' ), but using DISTINCTCOUNT is safer in case an order appears more than once. The good part is you don’t need to manually group anything—the visual and context do the grouping for you, so the measure stays simple and works in all scenarios.
Thanks, but I do not want to drop this measure in a visual. I need it for further calculation(s). danextian's solutions works for me.