Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

"Pivoting" a table using DAX

Pivoting a table to use in a Histogram
2 hours ago

Hello, my data currently looks like this. 

AgeCount
233020
454736
572987

 

Basically, the client counted buyers by buyer age. I want to show this count in a histogram, with age buckets like ">20", "20-29", etc. To do this, I used a DAX calculated column. The client also wants to see percentages, so I created another DAX calculated column that takes each Count value and divides it by the total Count column sum. The table looks like this now. 

Age

Count

Age Bucket

Percentage
233020

20-29

12%
45473640-4915%
57298750-596%

 

However, the client wants a table on the dashboard that looks like this: 

Metric

20-2940-4950-59
Count302047362987
Percentage12%15%6%

 

Is there a good way to do this, I am currently exploring using SUMMARIZECOLUMNS.

 
  • In the formatting options for a matrix, under 'values' theres a 'show on rows' option.  If you turn this on, then put [Age Bucket] in columns and both [Count] and [Percentage] in values, then this should get you the result you want.  You may have to make Count and Percentage measures, but these can just be like:

    CountMeasure = SUM('YourTableName'[Count]) 

1 Reply

  • In the formatting options for a matrix, under 'values' theres a 'show on rows' option.  If you turn this on, then put [Age Bucket] in columns and both [Count] and [Percentage] in values, then this should get you the result you want.  You may have to make Count and Percentage measures, but these can just be like:

    CountMeasure = SUM('YourTableName'[Count])