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
Kpham
Resolver I
Resolver I

Remove empty cells in the row

Dataset:

PersonCar Preference
aAudi
aBMW
aMercedes
bToyota
bNissan
cMercedes
cKIA
cVW

 

Desired Power BI  visual:

 

PersonCar1Car2Car3Car4
aAudiBMWMercedesVW
bToyotaNissanBMW 
cMercedesKIAVW 

 

How can I achieve this?

1 ACCEPTED SOLUTION

Hi @Kpham ,

if you want them in separate column, you have to add an index column for the column number to your table: 

https://www.youtube.com/watch?v=-3KFZaYImEY 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

5 REPLIES 5
v-eqin-msft
Community Support
Community Support

Hi @Kpham ,

I am not sure if there is a more efficient way...

 

My approach is as follows:

1. Sort the table by grouping by Person column

rank =
VAR a = [Person]
VAR t1 =
    FILTER ( ALL ( 'Table' ), 'Table'[Person] = a )
RETURN
    RANKX ( t1, [Car Preference],, DESC, SKIP )

2. Create a new Table with distinct person 

Table 2 =
DISTINCT ( SELECTCOLUMNS ( 'Table', "Person", [Person] ) )

3. Add columns separately by rank column. (Take the Car1 column as an example)

Car1 =
CALCULATE (
    MAX ( 'Table'[Car Preference] ),
    FILTER ( 'Table', 'Table'[Person] = 'Table 2'[Person] && 'Table'[rank] = 1 )
)

My final output looks like this:

10.22.7.1.PNG

Please take a look at my pbix file here.

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

Best Regards,
Eyelyn Qin

FrankAT
Community Champion
Community Champion

Hi @Kpham 

with your dataset I get the following solution:

 

20-10-_2020_16-55-50.png

 

Cars = CONCATENATEX(VALUES('Table'[Car Preference]),'Table'[Car Preference],", ")

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

Hi @Kpham ,

if you want them in separate column, you have to add an index column for the column number to your table: 

https://www.youtube.com/watch?v=-3KFZaYImEY 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

amitchandak
Super User
Super User

@Kpham , I think this needs to be done in M. Let us check with the experts

 

@ImkeF , can you help with this

 

Hi,

 

Thank you for you time. I just reviewed my post and edited the input dataset

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.

Top Solution Authors