# Dyanmic Grouping DAX Calculation in DAX Patterns Class

HI Team,

Have a question regarding Dynamic Group customers by Ranking

In that Sam created disconnected table for Top 5 and 5-20 and the rest and he created DAX formula as below

Didnt understand how this formula works and y he used count rows can any one help me understand in a better highly appreciated

CALCULATE([Total Sales] ,FILTER(VALUES(Customer_Data[Customer Names]),
COUNTROWS( FILTER(‘Customer Ranking’,
RANKX(ALL(Customer_Data),[Total Sales],DESC) > ‘Customer Ranking’[MIn] &&
RANKX(ALL(‘Customer_Data’),[Total Sales],DESC)<= ‘Customer Ranking’[Max]))>0))

Thanks,
varun G

@varuntableau5
Below comments are quoted from the video Examples of Advanced Dax in course Ultimate Beginners Guide to DAX.

to understand above function recall context concept. for each cell in pivot table this measure will be calculated. For first cell the context is customer from 0 to 50. So the min value is 0 and max value is 50. VALUES( Customers[Customer Name] ), this will give unique list of customers names. Now we have to rank all customers based on profit. After ranking we want only those customers which are within range of 0 to 50. The filter function filter out those customers which do not belong to this range (COUNTROWS() >0). Now calculate will calculate total profit for filtered customers and visualize it.
The same logic keep repeating for each cell (customer group).

Thanks.

Hi @varuntableau5, we hope that you are having a great experience using the Support Forum so far. We’ve recently launched the Enterprise DNA Forum User Experience Survey, please feel free to answer it and give your insights on how we can further improve the Support forum. Thanks!