Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
thealaird
New Member

dax help - calculating totals and subtotals from strings

hi guys,

I have a csv that has several columns containing strings e.g. apple;banana;orange;apple

the strings are outputs from a list of over 200 potential 'fruits' so I cannot name individually within the code

Is it possible to write a dynamic DAX code to extract the total number of fruits per column as well as total number of fruits by fruit

i would like to be able to output a simple bar chart like below

thealaird_0-1704716178737.png

 

 

1 ACCEPTED SOLUTION
sjoerdvn
Super User
Super User

I would recommend to not use DAX for this, but to unpivot the columns when loading the data, e.g. using power query.
https://learn.microsoft.com/en-us/power-query/unpivot-column

 

View solution in original post

1 REPLY 1
sjoerdvn
Super User
Super User

I would recommend to not use DAX for this, but to unpivot the columns when loading the data, e.g. using power query.
https://learn.microsoft.com/en-us/power-query/unpivot-column

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.