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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
zhannak
Frequent Visitor

Splitting a column into few new columns based on category

Hi everyone,

 

I'm new to Power BI and trying to build a new table (table) from the bigger one (initial_table) based on some calculations and filtering. I couldn't find a solution to my problem myself. My table is quite big but in general it looks similarly as in this example:

 

CountrySourceSum
AustriaInternal23
AustriaExternal18
AustriaOther99
FranceExternal44
FranceInternal57
ItalyInternal11

 

To create it, I use the following DAX command: table = SUMMARIZECOLUMNS(initial_table[Country],initial_table[Source],"Sum",[Sum]), where Sum metric is the sum of prices per country and per source calculated as Sum = CALCULATE(SUM(initial_table[Price]),ALLEXCEPT(initial_table,initial_table[Source],new_table[Country]))

 

What I would like to do is to split column "Source" into separate columns reflecting data for the underlying sources per country (where the fields with no data should be replaced with the blank field), i.e. I want the final tabel to be the following:

 

CountryInternalExternalOther
Austria231899
France5744 
Italy11  

 

I tried creating the metric which should reflect such selection for each of the columns and then assign a new column to that metric, for instance for Internal column it would be the following two lines respectively:

 
Internal_metric = IF(SELECTEDVALUE(table[Source])="Internal",[Sum],BLANK())
Internal = Internal_metric
 
However, the values in my new column do not make sense - the sum becomes the sum of prices for all countries, not just for one particular country I am looking at. Also, even if they were to be correct, if I remove Source and Sum columns (which I need to do in the end), the data dissapears. One more complication is that it's not possible to use pivoting in the query editor because I used DAX to create the table. How can I solve that? 
 
Thanks for any help,
Zhanna
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@zhannak , Try like

 

SUMMARIZE(initial_table, initial_table[Country],"Internal", sumx(filter(initial_table,initial_table[Source] ="Internal"), [Sum])
,"External", sumx(filter(initial_table,initial_table[Source] ="External"), [Sum])
,"Other", sumx(filter(initial_table,initial_table[Source] ="Other"), [Sum]) )

 

 

As the combinations are unique, I doubt it will sum up or you can use Avg

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
zhannak
Frequent Visitor

Many thanks @amitchandak, it works!

amitchandak
Super User
Super User

@zhannak , Try like

 

SUMMARIZE(initial_table, initial_table[Country],"Internal", sumx(filter(initial_table,initial_table[Source] ="Internal"), [Sum])
,"External", sumx(filter(initial_table,initial_table[Source] ="External"), [Sum])
,"Other", sumx(filter(initial_table,initial_table[Source] ="Other"), [Sum]) )

 

 

As the combinations are unique, I doubt it will sum up or you can use Avg

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.