Forum Discussion
ManchevB
Helper II
1 year agoSplitting a column from a PowerBI formula
Hi all, I have this formula here: 7.SkillAvailabilityByCountry = VAR AllCountries = VALUES('Employees'[CountryName]) RETURN ADDCOLUMNS ( 'Skills Data', "Country", ...
- 1 year ago
ManchevB
You may try genreating the above table and spliting the column CountriesWithoutSkill into rows using Power Query:let AllCountries = List.Distinct(Employees[CountryName]), Source = #"Skills Data", AddCountry = Table.AddColumn( Source, "Country", each let skill = [SkillName], countries = List.Distinct(Table.SelectRows(Employees, (r) => r[SkillName] = skill)[CountryName]) in Text.Combine(List.Sort(countries), ", ") ), AddCountriesWithoutSkill = Table.AddColumn( AddCountry, "CountriesWithoutSkill", each let selected = if [Country] = "" then {} else Text.Split([Country], ", "), diff = List.Difference(AllCountries, selected) in Text.Combine(List.Sort(diff), ", ") ), TransformColumn = Table.TransformColumns(AddCountriesWithoutSkill, {{"CountriesWithoutSkill", each Text.Split(_, ", "), type list}}), ExpandCountriesWithoutSkill = Table.ExpandListColumn(TransformColumn, "CountriesWithoutSkill") in ExpandCountriesWithoutSkill
Fowmy
Super User
1 year agoManchevB
You may try genreating the above table and spliting the column CountriesWithoutSkill into rows using Power Query:
let
AllCountries = List.Distinct(Employees[CountryName]),
Source = #"Skills Data",
AddCountry = Table.AddColumn(
Source,
"Country",
each
let
skill = [SkillName],
countries = List.Distinct(Table.SelectRows(Employees, (r) => r[SkillName] = skill)[CountryName])
in
Text.Combine(List.Sort(countries), ", ")
),
AddCountriesWithoutSkill = Table.AddColumn(
AddCountry,
"CountriesWithoutSkill",
each
let
selected = if [Country] = "" then {} else Text.Split([Country], ", "),
diff = List.Difference(AllCountries, selected)
in
Text.Combine(List.Sort(diff), ", ")
),
TransformColumn = Table.TransformColumns(AddCountriesWithoutSkill, {{"CountriesWithoutSkill", each Text.Split(_, ", "), type list}}),
ExpandCountriesWithoutSkill = Table.ExpandListColumn(TransformColumn, "CountriesWithoutSkill")
in
ExpandCountriesWithoutSkill