Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Split table into columns based on unique values

Hi guys,

 

I'd like to split this dummy table into several columns and populate with 1's and 0's, based on the unique values in the Year/Qtr column.

 

Current layout

NameYear/Qtr
Dave2021Q1
John2021Q1
John2021Q2
Patricia2021Q3
Patricia2021Q4
Claire2022Q1
Dave2022Q2
Claire2022Q3
Claire2022Q4

 

Desired layout

Name2021Q12021Q22021Q32021Q42022Q12022Q22022Q32022Q4
Dave1----1--
John11------
Patricia--11----
Claire----1-11

 

or

 

Name2021Q12021Q22021Q32021Q42022Q12022Q22022Q32022Q4
Dave1----1--
John11------
John11------
Patricia--11----
Patricia--11----
Claire----1-11
Dave1----1--
Claire----1-11
Claire----1-11

 

The only difference in the two is that the second desired layout uses the same rows as the current layout.

 

What's key here is that I need it to create columns based on unique values, hence no hardcoding of columns as that would force me to re-code the query as soon as a new quarter starts.

 

Thank you so much for the help!

1 Reply

  • Hi Anonymous ,

     

    Create a new measure like this:

    _countName = DISTINCTCOUNT(yourTable[Name])

     

    Then put it all into a matrix visual like this:

     

    Pete