Forum Discussion
Arjun_reddy
3 years agoHelper I
dax query
Hi Community team, I have category, year, totalsales fields in sales table I want to write a dax query - which category is having the highest value and what is the max value on total sales on ca...
- 3 years ago
Hi Arjun_reddy
Sorry, I didn't see that you need it for the last year.
In this case the daxes are :
1. Basic sum of salesSum of Sales = sum('Table'[sales])2. Maximum sum of sales by category and last year :Max Sales by Category and Last year =VAR MaxSalesYear =MAX('Table'[year])VAR CategorySales =SUMMARIZE(FILTER('Table', 'Table'[year] = MaxSalesYear),'Table'[Category],"TotalSales", [Sum of Sales])VAR MaxCategorySales =MAXX(CategorySales, [TotalSales])RETURNMaxCategorySales3. For CategoryMaxSalesCategory =VAR MaxSalesYear =MAX('Table'[year])VAR CategorySales =SUMMARIZE(FILTER('Table', 'Table'[year] = MaxSalesYear),'Table'[Category],"TotalSales", [Sum of Sales])VAR MaxCategorySales =MAXX(CategorySales, [TotalSales])RETURNMAXX(FILTER(CategorySales, [TotalSales] = MaxCategorySales),[Category])Result:Please consider Accepting it as the solution to help the other members find it more quickly
- 3 years ago
Hi,
Please find attached the PBI file.
Hope this helps.
Arjun_reddy
3 years agoHelper I
Hi Ashish Mathur,
I have implemented the same way to my report, its working fine, really awesome
Thanks a lot Ashish and Ritaf
Ashish_Mathur
3 years agoSuper User
You are welcome. If my previous reply helped, please mark that reply as Answer.