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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
ManchevB
Helper I
Helper I

PowerBI breaking a table from formula

Hi all, 

 

I have this PBI expression that I am working on here: 

 

SkillsCountriesTable =
ADDCOLUMNS(
    VALUES('Skills Data'[SkillName]),  -- Get all distinct skills
    "CountryWithSkill",
    CONCATENATEX(
        CALCULATETABLE(
            VALUES('Employees'[CountryName]),  -- Get countries for each skill
            'Skills Data'[SkillName] = EARLIER('Skills Data'[SkillName])
        ),
        'Employees'[CountryName], ", "  -- Concatenate countries that have the skill
    ),
    "CountriesWithSkill",
    CONCATENATEX(
        CALCULATETABLE(
            VALUES('Employees'[CountryName]),  -- Get countries for each skill
            'Skills Data'[SkillName] = EARLIER('Skills Data'[SkillName])
        ),
        'Employees'[CountryName], ", "
    ),
    "CountriesWithoutSkill",
    CONCATENATEX(
        FILTER(
            VALUES('Employees'[CountryName]),  -- Get all countries that do not have the skill
            NOT('Employees'[CountryName] IN
                CALCULATETABLE(
                    VALUES('Employees'[CountryName]),
                    'Skills Data'[SkillName] = EARLIER('Skills Data'[SkillName])
                )
            )
        ),
        'Employees'[CountryName], ", "
    )
)
 
The result is:
 

 

and what I would like to have is:

 

in CountryWithSkill - to have each country separately and not in 1 line

in CountriesWithoutSkill - to have each country separately and not in 1 line ( these are the countries that doesn't have that skill )

in CountriesWithSkill - to have each country separately and not in 1 line ( these are the countries that also have the respective skill )

 

I am available if more information is needed.

 

Appreciate everyone who would be able to advise. 

 

Thank you,

Boris

 

1 ACCEPTED SOLUTION
ManchevB
Helper I
Helper I

I managed to split the table CountriesWithoutSkill into a new column and then applied page filters to see only what is relevant

View solution in original post

6 REPLIES 6
ManchevB
Helper I
Helper I

I managed to split the table CountriesWithoutSkill into a new column and then applied page filters to see only what is relevant

Hi @ManchevB ,

 

Thanks for your feedback.

 

Best regards,

Adamk Kong

v-kongfanf-msft
Community Support
Community Support

Hi @ManchevB ,

 

Maybe you can modify formula like below:

SkillsCountriesTable = 
ADDCOLUMNS(
    VALUES('Skills Data'[SkillName]),
    "CountryWithSkill",
    CALCULATETABLE(
        VALUES('Employees'[CountryName]),
        'Skills Data'[SkillName] = EARLIER('Skills Data'[SkillName])
    ),
    "CountriesWithSkill",
    CALCULATETABLE(
        VALUES('Employees'[CountryName]),
        'Skills Data'[SkillName] = EARLIER('Skills Data'[SkillName])
    ),
    "CountriesWithoutSkill",
    EXCEPT(
        VALUES('Employees'[CountryName]),
        CALCULATETABLE(
            VALUES('Employees'[CountryName]), 
            'Skills Data'[SkillName] = EARLIER('Skills Data'[SkillName])
        )
    )
)


Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

If you do not want them in a single linem then why are you using the CONCATENATEX() function?  Share some data to work with, explain the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
FarhanJeelani
Super User
Super User

Hi @ManchevB ,

It looks like the issue is that your CONCATENATEX function is combining all countries into a single line, but you want each country listed separately, presumably one per row.

To achieve this, you don’t need to use CONCATENATEX  at all, as it is meant for combining values into a single text string. Instead, you can create separate tables or adjust your data model.

Here’s a solution:

Modify Your DAX to Create Separate Rows

SkillsCountriesTable =
SELECTCOLUMNS(
    CROSSJOIN(
        VALUES('Skills Data'[SkillName]),
        VALUES('Employees'[CountryName])
    ),
    "SkillName", 'Skills Data'[SkillName],
    "Country", 'Employees'[CountryName],
    "HasSkill",
    IF(
        'Employees'[CountryName] IN
            CALCULATETABLE(
                VALUES('Employees'[CountryName]),
                'Skills Data'[SkillName] = EARLIER('Skills Data'[SkillName])
            ),
        "Yes",
        "No"
    )
)

 Please mark this post as solution if it helps you. Appreciate Kudos.

Thanks for the suggestion, I am aiming to have 3 columns:

 

in CountryWithSkill - to have each country separately and not in 1 line

in CountriesWithoutSkill - to have each country separately and not in 1 line ( these are the countries that doesn't have that skill )

in CountriesWithSkill - to have each country separately and not in 1 line ( these are the countries that also have the respective skill )

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors