Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

have only one max value in calculate column

Hi , I have 3 columns : Id, category and quantity, i want add a calculate columns that i have only one max value in same category, can i achive that with calculate columns?
Add screen shot what i want:

 

   want Output
IDCategoryQuantityMax quantity
1A10
2A10
3A33
4A20
5A10
6B10
7B10
8B22
9B20
10B10
11C10
12C20
13C20
14C20
15C44
1 ACCEPTED SOLUTION

@Anonymous 

 

MAX = 
VAR _current_qty = 'Table'[Quantity] 
VAR _current_cateogry = 'Table'[Category]
VAR _max_per_category = 
    CALCULATE(MAX('Table'[Quantity]), REMOVEFILTERS('Table'), 'Table'[Category] = _current_cateogry) 
VAR _id_with_max = 
    MINX(
        FILTER(
            'Table',
            'Table'[Category] = _current_cateogry 
            && 'Table'[Quantity] = CALCULATE(MAX('Table'[Quantity]), REMOVEFILTERS('Table'), 'Table'[Category] = _current_cateogry)
        ),
    'Table'[ID]
)

VAR _result = 
    IF(_current_qty = _max_per_category && 'Table'[ID] = _id_with_max, _current_qty, 0)
RETURN
    _result

 

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

6 REPLIES 6
sanalytics
Super User
Super User

@Anonymous 

 

You can use below formula also

sanalytics_0-1652706315122.png

 

Hope it will help you.

 

Regards

sanalytics

SpartaBI
Community Champion
Community Champion

@Anonymous 

 

MAX = 
VAR _current_qty = 'Table'[Quantity] 
VAR _current_cateogry = 'Table'[Category]
VAR _max_per_category = 
    CALCULATE(MAX('Table'[Quantity]), REMOVEFILTERS('Table'), 'Table'[Category] = _current_cateogry) 
VAR _result = 
    IF(_current_qty = _max_per_category, _current_qty, 0)
RETURN
    _result

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Anonymous
Not applicable

Hi thank you for your fast reply it doesnt work, as you can see in category b i have 2 max values and i only want one value.

@Anonymous @ which one? 🙂 what is the desired logic for ties?

Anonymous
Not applicable

i want only one max value per category so if ties only one and the other one will be 0

 

@Anonymous 

 

MAX = 
VAR _current_qty = 'Table'[Quantity] 
VAR _current_cateogry = 'Table'[Category]
VAR _max_per_category = 
    CALCULATE(MAX('Table'[Quantity]), REMOVEFILTERS('Table'), 'Table'[Category] = _current_cateogry) 
VAR _id_with_max = 
    MINX(
        FILTER(
            'Table',
            'Table'[Category] = _current_cateogry 
            && 'Table'[Quantity] = CALCULATE(MAX('Table'[Quantity]), REMOVEFILTERS('Table'), 'Table'[Category] = _current_cateogry)
        ),
    'Table'[ID]
)

VAR _result = 
    IF(_current_qty = _max_per_category && 'Table'[ID] = _id_with_max, _current_qty, 0)
RETURN
    _result

 

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.