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
Anonymous
Not applicable

Combine values with measure

Hi there,

Lets say I have these values:

 

MoneyState

500

CA
200FL
100CO
250AL
200NY

 

I want to combine the values of 'CA', 'FL' and 'CO'. So that will be 500+200+100 = 800. I want to give this a new column name, for example 'best-states'. A measure needs to be able to do this for me, but I don't know how. The other values of the states needs to stay the same.

 

Thanks!

1 ACCEPTED SOLUTION
lkalawski
Memorable Member
Memorable Member

Hi, 

 

You can create new column:

Group State = SWITCH('Table'[State],
"CA", "best-state",
"FL", "best-state",
"CO", "best-state",
'Table'[State])

And use it to create table or visuals:

Ex1.png 



_______________
If I helped, please accept the solution and give kudos! 😀

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous 

Better create a new column

New column =

Switch(True(),

[State] in {"CA","FL",,"CO"},"best-states",

//Other connditions

"Oher states"

}

lkalawski
Memorable Member
Memorable Member

Hi, 

 

You can create new column:

Group State = SWITCH('Table'[State],
"CA", "best-state",
"FL", "best-state",
"CO", "best-state",
'Table'[State])

And use it to create table or visuals:

Ex1.png 



_______________
If I helped, please accept the solution and give kudos! 😀

Anonymous
Not applicable

@lkalawski 

If I try this my other states are gone, only those 3 are there

 

Edit: my Power BI wasn't showing it well, it works !

az38
Community Champion
Community Champion

Hi @Anonymous 

how do you define values of 'CA', 'FL' and 'CO'? If it always will be a constant try a measure

Measure = 
IF(SELECTEDVALUE(Table[State]) IN {"CA", "FL", "CO"}, 
CALCULATE(SUM(Table[Money]), Table[State] IN {"CA", "FL", "CO"}),
SELECTEDVALUE(Table[Money])
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 Yes they are constant. This seems helpful, but I have more states that I want to combine and give a new name. How can I do that? And where in your measure is the new column name?

Thanks!

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.