cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KH_Mike
Helper II
Helper II

How to change the field value by using DAX

Hi All,

 

Right now I create a table like below. Those fields are in the Table already. I would like to change the value when Table[Cat] = A and Table[Sub-Cat] = CC  to Table[Sub-Cat] = BB. Is it possible to acheive it by just by using DAX formalar (Measure)?

 

Before

CatSub-Catsum(Volume)
AAA0
ABB1
ACC2
BAA3
BBB4
BCC5
CAA6
CBB7
CCC8

 

After

CatSub-Catsum(Volume)
AAA0
ABB3
BAA3
BBB4
BCC5
CAA6
CBB7
CCC8

 

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Picture1.png

 

Volume Total by the condition : =
SWITCH (
TRUE (),
SELECTEDVALUE ( Categories[Cat] ) = "A"
&& SELECTEDVALUE ( Sub_Categories[Sub-Cat] ) = "CC", BLANK (),
SELECTEDVALUE ( Categories[Cat] ) = "A"
&& SELECTEDVALUE ( Sub_Categories[Sub-Cat] ) = "BB",
CALCULATE (
SUM ( Data[sum(Volume)] ),
Categories[Cat] = "A",
Sub_Categories[Sub-Cat] = "BB"
|| Sub_Categories[Sub-Cat] = "CC"
),
SUM ( Data[sum(Volume)] )
)

 

 

Link to the sample pbix file 

 

 


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

amitchandak
Super User
Super User

@KH_Mike , I DAX you have to create a new column

 

Sub Cat New =

if([Cat]= "A" && [Sub Cat] ="CC", "BB", [Sub Cat])

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Hi @amitchandak @Jihwan_Kim

 

Is it possible to do it in "Measure" instead of adding new column / create new table behind? Thank you.

Hi,

Please try the below measure.

The columns that are refered in the measure are from the same table.

 

Volume Total by the condition : =
SWITCH (
TRUE (),
SELECTEDVALUE ( Data[Cat] ) = "A" && SELECTEDVALUE ( Data[Sub-Cat] ) = "CC", BLANK (),
SELECTEDVALUE ( Data[Cat] ) = "A" && SELECTEDVALUE ( Data[Sub-Cat] ) = "BB",
CALCULATE (
SUM ( Data[sum(Volume)] ),
FILTER( ALL(Data), Data[Cat] = "A" &&
Data[Sub-Cat] in { "BB","CC"})
),
SUM ( Data[sum(Volume)] )
)
 
 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors