Forum Discussion

Mahmoud23's avatar
Mahmoud23
Regular Visitor
1 year ago
Solved

Need Help with data

Help with data. I have a data table from Spotify that contains a column recording the number of artists, and some cells have more than one artist. I want a function or method to create a card ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for the reply from parry2k , please allow me to provide another insight:
    Hi  Mahmoud23 ,

    I couldn't open your pbix link, I created my own relevant sample data:

    Here are the steps you can follow:

    1. Duplicate the table in Power Query, delete columns for splitting into multiple columns, select all columns for Unpivot Columns.

    Select [track_name] -- Remove

    Table_copy – select [act_name] – Split column – By Delimiter.

    Select all columns – Unpivot Columns.

    Select [Attribute] – Remove.

    Select [Value] – Duplicate Column.

    2. Create measure.

    Measure =
    var _select=SELECTEDVALUE('Table'[track_name])
    var _art=MAXX(FILTER(ALL('Table'),'Table'[track_name]=_select),[art_name])
    var _table=
    FILTER('Table_copy',CONTAINSSTRING(_art,[Value])=TRUE())
    var _table2=
    ADDCOLUMNS(
        _table,"Count",COUNTX(FILTER(ALL('Table'),CONTAINSSTRING('Table'[art_name],[Value])=TRUE()),[track_name]))
    return
    CONCATENATEX(_table2,[Value]&"-"&[Count]," ")

    3. Result:

     

    Best Regards,

    Liu Yang

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