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.
Ritaf1983
3 years agoSuper User
Hi Arjun_reddy
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523