March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have the following data and need the max sales grouped by year along with year in which maximum sales was done.
Expected output: 30 and 2022
Solved! Go to Solution.
@Anonymous please try if that works for you. You need two measures:
Max Sales =
Maxx ( values (Table[Year]), CALCULATE(sum(Table[Sales])))
MaxYear =
var MaxSales= Maxx ( values (Tabele[Year]), CALCULATE(sum(Table[Sales])))
return
CALCULATE(max( Table[Year]), filter ( values (Table[Year]), CALCULATE(sum(Table[Sales])= MaxSales)))
Hope that helps.
Best.
If you want to use TOPN -Function, this might work:
Maxx(TOPN ( 1,
VALUES ( Table[Year] ),
calculate(SUM ( Table[Sales] )),
DESC
),Table[Year])
@Anonymous, if I understand correctly that you want the sum of total sales, but only sum the max of each year? then try sth. like this:
Total Sales = Sumx( Values ( Date[Year]), Max ( 'Table'Sales))
No. I want to display the total sales of the year ( For example: for 2022 sales =10+20) which has the maximum total sales (2021 has 15, 2022 has 30, 2023 has 6). The output should be 30 and year 2022
Hi @Anonymous
How would yoy like to disply these results? For example on a card visual? or in a matrix visual where you sluce by year and in each row you want to see the sales of the year and beside it the maxumum sales over all years and beside them the year that has the maximum sales?
On a card visual
@Anonymous
You can use the following
MAX Sales =
MAXX (
VALUES ( 'Date'[Year] ),
[Sales]
)
MAX Sales Year =
TOPN ( 1,
VALUES ( 'Date'[Year] ),
[Sales],
DESC
)
No. I want to display the total sales of the year ( For example: for 2022 sales =10+20) which has the maximum total sales (2021 has 15, 2022 has 30, 2023 has 6). The output should be 30 and year 2022
@Anonymous
This is exactly what it does. [Sales] is actally a measure [Sales] = SUM ( Sales[Sales] )
Alternatively you can use the fllowing:
MAX Sales =
MAXX (
VALUES ( 'Date'[Year] ),
SUM ( Sales[Sales] )
)
MAX Sales Year =
TOPN ( 1,
VALUES ( 'Date'[Year] ),
SUM ( Sales[Sales] ),
DESC
)
Of course [Sales] can be SUM ( Sales[Sales] )
No, it's not showing the value. A table of multiple values was supplied where a single value was expected.
Hi @Anonymous
Please try this
MAX Sales =
MAXX (
VALUES ( 'Date'[Year] ),
CALCULATE ( SUM ( Sales[Sales] ) )
)
MAX Sales Year =
TOPN ( 1,
VALUES ( 'Date'[Year] ),
CALCULATE ( SUM ( Sales[Sales] ) ),
DESC
)
@Anonymous please try if that works for you. You need two measures:
Max Sales =
Maxx ( values (Table[Year]), CALCULATE(sum(Table[Sales])))
MaxYear =
var MaxSales= Maxx ( values (Tabele[Year]), CALCULATE(sum(Table[Sales])))
return
CALCULATE(max( Table[Year]), filter ( values (Table[Year]), CALCULATE(sum(Table[Sales])= MaxSales)))
Hope that helps.
Best.
Thank you .. this works
If you want to use TOPN -Function, this might work:
Maxx(TOPN ( 1,
VALUES ( Table[Year] ),
calculate(SUM ( Table[Sales] )),
DESC
),Table[Year])
Can please send sample file with demo data?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
8 |
User | Count |
---|---|
37 | |
32 | |
16 | |
16 | |
12 |