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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
GirishS3
New Member

undefined

Want to swap small price with large price and middle price remain same

             Input Table                                                                         Output             
category     Sub_Cat               Price                                                  column
   A                  Small                100                                                    300
   A                  Medium           200                                                     200
   A                   Large              300                                                      100
   B                   Small              200                                                       400
   B                  Medium           300                                                      300
   B                 Large                400                                                       300

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @GirishS3 

 

You can try the following methods.

Measure:

Measure = 
Var Large=CALCULATE(MAX('Table'[Price]),ALLEXCEPT('Table','Table'[category]))
Var Small=CALCULATE(MIN('Table'[Price]),ALLEXCEPT('Table','Table'[category]))
Return
SWITCH(TRUE(),
SELECTEDVALUE('Table'[Sub_Cat])="Medium",SUM('Table'[Price]),
SELECTEDVALUE('Table'[Sub_Cat])="Small",Large,
SELECTEDVALUE('Table'[Sub_Cat])="Large",Small )

vzhangti_0-1661325033349.png

 

Column:

Column = 
Var Large=CALCULATE(MAX('Table'[Price]),FILTER(ALL('Table'),[category]=EARLIER('Table'[category])))
Var Small=CALCULATE(MIN('Table'[Price]),FILTER(ALL('Table'),[category]=EARLIER('Table'[category])))
Return
SWITCH(TRUE(),
[Sub_Cat]="Medium",[Price],
[Sub_Cat]="Small",Large,
[Sub_Cat]="Large",Small )

vzhangti_1-1661325091666.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @GirishS3 

 

You can try the following methods.

Measure:

Measure = 
Var Large=CALCULATE(MAX('Table'[Price]),ALLEXCEPT('Table','Table'[category]))
Var Small=CALCULATE(MIN('Table'[Price]),ALLEXCEPT('Table','Table'[category]))
Return
SWITCH(TRUE(),
SELECTEDVALUE('Table'[Sub_Cat])="Medium",SUM('Table'[Price]),
SELECTEDVALUE('Table'[Sub_Cat])="Small",Large,
SELECTEDVALUE('Table'[Sub_Cat])="Large",Small )

vzhangti_0-1661325033349.png

 

Column:

Column = 
Var Large=CALCULATE(MAX('Table'[Price]),FILTER(ALL('Table'),[category]=EARLIER('Table'[category])))
Var Small=CALCULATE(MIN('Table'[Price]),FILTER(ALL('Table'),[category]=EARLIER('Table'[category])))
Return
SWITCH(TRUE(),
[Sub_Cat]="Medium",[Price],
[Sub_Cat]="Small",Large,
[Sub_Cat]="Large",Small )

vzhangti_1-1661325091666.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

MahyarTF
Memorable Member
Memorable Member

Hi,

Use below Code to create a column in your table :

_NewPrice =
            if (sheet121[Sub-Cat] = "Small",
                CALCULATE(max(Sheet121[Price]),
                        Sheet121[Sub-Cat] = "Large",
                        ALLEXCEPT(sheet121, Sheet121[Category])
                        ),
                Sheet121[Price])
MahyarTF_0-1661075827682.png

 

Appreciate your Kudos
Mahyartf
Fowmy
Super User
Super User

@GirishS3 
If you need a DAX solution, add the folloiwng Calculated Column to your table as follows

New Price = 
VAR __SubC = Table1[Sub_Cat]
RETURN 
SWITCH(
    TRUE(),
    __SubC = "Small",
        CALCULATE(
            max(Table1[Price]),
            Table1[Sub_Cat] = "Large",
            ALLEXCEPT(Table1,Table1[Category])
        ),
    __SubC = "Large",
        CALCULATE(
            max(Table1[Price]),
            Table1[Sub_Cat] = "Small",
            ALLEXCEPT(Table1,Table1[Category])
        ),
    Table1[Price]
)

Fowmy_0-1661073159021.png

 






 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.