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
Hello,
I am trying to calculate MAX units per ID (I am only interested in the highest value in the Units column for every ID.
My Example data in Table 1.
Date ID Units
2020-10-01 M2005 322
2020-10-05 B2015 125
2020-10-08 B2014 223
2020-11-12 M2006 1934
2021-07-09 M2110 16
2021-07-12 M2111 19
2021-07-12 M2112 27
2021-07-13 M2104 5733
2021-07-13 M2104 180
2021-07-15 B2108 167
2021-07-15 B2105 9
2021-11-03 B2109 57
2021-11-05 B2102 50
2021-11-11 M2003 9829
2021-11-17 B2107 2064
2021-11-17 B2107 380
2021-11-29 M2006 1305
2022-03-24 B2107 168
2022-03-23 B2113 100
2022-03-04 B2201 18
2022-03-08 B2203 16
2022-03-18 M2106 2336
I have a calendar table with Date and Year Month connected to Table 1.
The result I want is this table:
Year Month | Units |
2020-10 | 670 |
2020-11 | 1934 |
2021-07 | 5971 |
2021-11 | 12000 |
2022-03 | 2470 |
I Have tried these Measures:
Solved! Go to Solution.
Thank you!
Since I did not have the row number in my actual table it did not work for me. But the idea to create a column with 1 or 0 was a great idea.
What worked for me was this code:
Dont understand how you are getting 5971 on 2021-07, 12000 on 2021-11 and 2470 on 2022-03.
Can you provide little bit more clarification.
Regards
sanalytics
Hi @majos978,
Could you please share the output that you want?
I think i'm not getting the all idea.
Proud to be a Super User!
Sorry, I have ordered my Table 1 by ID and added a row number.
I want to only keep the maximum value per ID of Units. This means I want to remove row 6, 7, 16, 18.
Row Date ID Units
1 2020-10-08 B2014 223
2 2020-10-05 B2015 125
3 2021-11-05 B2102 50
4 2021-07-15 B2105 9
5 2021-11-17 B2107 2064
6 2021-11-17 B2107 380
7 2022-03-24 B2107 168
8 2021-07-15 B2108 167
9 2021-11-03 B2109 57
10 2022-03-23 B2113 100
11 2022-03-04 B2201 18
12 2022-03-08 B2203 16
13 2021-11-11 M2003 9829
14 2020-10-01 M2005 322
15 2020-11-12 M2006 1934
16 2021-11-29 M2006 1305
17 2021-07-13 M2104 5733
18 2021-07-13 M2104 180
19 2022-03-18 M2106 2336
20 2021-07-09 M2110 16
21 2021-07-12 M2111 19
22 2021-07-12 M2112 27
I hope that clarifies it.
Thank you!
Create a Calculated column to discard the duplicated id.Below is the code
Hope this will help you.
Regards
sanalytics
If it is your solution then please like and accept it as solution
Thank you!
Since I did not have the row number in my actual table it did not work for me. But the idea to create a column with 1 or 0 was a great idea.
What worked for me was this code:
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 |
---|---|
133 | |
90 | |
88 | |
64 | |
58 |
User | Count |
---|---|
203 | |
141 | |
107 | |
73 | |
70 |