user14288796
user14288796

Reputation: 15

DAX Formula Help: Summing Individual Digits in a Cell

I'm using Power Bi and need a DAX formula to do the following:

Column A contains the following data:

1234

5678

9101

I need Column B to sum each individual digit in a particular cell:

Column B

1+2+3+4 =10
5+6+7+8 = 26
9+1+0+1 = 11

What is a formula I can use to do this?

Upvotes: 1

Views: 263

Answers (1)

Priyanka2304
Priyanka2304

Reputation: 210

One way to get the output is to split the required column so that new resulting column has a digit which can further be summed up in a calculated column.

To Split the column follow the below steps:

  1. Under Home Tab select the Query editor/Transform Data/Edit queries option (option may vary as per the version of Power BI)
  2. Duplicate the column that holds the numbers which is to be added.
  3. Use the Split Column option under Home Tab(Transform section).
  4. Choose the option "By number of characters".
  5. Enter number of characters as 1 and "Repeatedly" under the Split option.
  6. Hit OK.
  7. Once the column is split into multiple columns, create a calculated column to add the split columns.
  8. After adding the calculated column which sums up the split column, hide the split columns so that the field list is managable.

Upvotes: 2

Related Questions