Forum Discussion

techlog's avatar
techlog
Frequent Visitor
2 years ago
Solved

Multiple rows into one based on similar column values

Hi, 

Is there any way we can display multiple rows having similar column values into single row till the columns which have duplicate/same value.

 

Example below - 

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi techlog ,

    Based on my testing, please try the following methods:

    1.Create the sample table.

    2.Create the new index column.

    3.Create the new measure to display multiple ID rows into single row.

    Multiple ID = 
    var _index = SELECTEDVALUE('Table'[Index])
    VAR _id = SELECTEDVALUE('Table'[Emp ID])
    RETURN
    IF(CALCULATE(SELECTEDVALUE('Table'[Emp ID]),FILTER(ALL('Table'),'Table'[Index] = _index-1)) = _id,BLANK(),_id)

    4.Create the new measure for each column that have multiple rows.

    Multi Name = 
    var _index = SELECTEDVALUE('Table'[Index])
    VAR _name = SELECTEDVALUE('Table'[Name])
    RETURN
    IF(CALCULATE(SELECTEDVALUE('Table'[Name]),FILTER(ALL('Table'),'Table'[Index] = _index-1)) = _name,BLANK(),_name)
    Multiple category = 
    var _index = SELECTEDVALUE('Table'[Index])
    VAR _cat = SELECTEDVALUE('Table'[Category])
    RETURN
    IF(CALCULATE(SELECTEDVALUE('Table'[Category]),FILTER(ALL('Table'),'Table'[Index] = _index-1)) = _cat,BLANK(), _cat)

    5.Drag the measure into the table.

    6.The result is shown below.

     

    Best Regards,

    Wisdom Wu

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

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi techlog ,

    Based on my testing, please try the following methods:

    1.Create the sample table.

    2.Create the new index column.

    3.Create the new measure to display multiple ID rows into single row.

    Multiple ID = 
    var _index = SELECTEDVALUE('Table'[Index])
    VAR _id = SELECTEDVALUE('Table'[Emp ID])
    RETURN
    IF(CALCULATE(SELECTEDVALUE('Table'[Emp ID]),FILTER(ALL('Table'),'Table'[Index] = _index-1)) = _id,BLANK(),_id)

    4.Create the new measure for each column that have multiple rows.

    Multi Name = 
    var _index = SELECTEDVALUE('Table'[Index])
    VAR _name = SELECTEDVALUE('Table'[Name])
    RETURN
    IF(CALCULATE(SELECTEDVALUE('Table'[Name]),FILTER(ALL('Table'),'Table'[Index] = _index-1)) = _name,BLANK(),_name)
    Multiple category = 
    var _index = SELECTEDVALUE('Table'[Index])
    VAR _cat = SELECTEDVALUE('Table'[Category])
    RETURN
    IF(CALCULATE(SELECTEDVALUE('Table'[Category]),FILTER(ALL('Table'),'Table'[Index] = _index-1)) = _cat,BLANK(), _cat)

    5.Drag the measure into the table.

    6.The result is shown below.

     

    Best Regards,

    Wisdom Wu

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

  • lkalawski's avatar
    lkalawski
    Resident Rockstar

    Hi techlog ,

    To do this, you can use matrix visual in Power BI and then in setting change to tabular view.

    Result: 

    Use matrix visual:

     

    And change to Tabular layout.

     

    Memorable Member | Former Super User
    If I helped, please accept the solution and give kudos! 
    Linkedin

     

  • hi techlog ,
    if you want to visualize the data then please use MATRIX visual in Power BI : 

    Steps to follow for above display of data : 

    1) Please have all the columns under Rows Field of Matrix Visual

    2) now go to row headers and toggle off the below option : 


    3) Under layout and style persist section, set below option :

     


    4) on your visual, click on this icon (at the lowest level ) to see all the columns 


    If this works for you, please mark the message as solution.
    Thanks,

    Ankita

    • techlog's avatar
      techlog
      Frequent Visitor

      Hi AnkitaaMishra 

      Thanks for the help.

       

      In the example I have just posted 3 columns, the concern here is if we have 10-12 columns or if the number of columns are more. We do not have the functionality of horizontal scrolling in the Matrix visual (Solved: PowerBI Matrix widget not showing horizonal scroll... - Power Platform Community (microsoft....) and in that case we were not able to see all the columns available in the matrix.

      So this solution will not work for the case where number of columns are more and require horizontal scrolling.

      This solution will work in case of less number of columns where horizontal scrolling is not required.