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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
KH_Mike
Helper III
Helper III

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 accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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])

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 accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.