ETedford
ETedford

Reputation: 71

PowerBI SUMMARIZE with 2 columns

So, having issues: 

To create the table with 2 columns using summarize, can't figure out how to get the 2nd column. So far I have:

=SUMMARIZE(table1,table1[column])

Which is fine for the first column. How can I add to this to make the 2nd column to be the same as the first column with padding to make 6 characters in length?

COLUMN 1        COLUMN 2
14325           014325
22              000022    
415263          415263    
ABC             000ABC

Upvotes: 1

Views: 1298

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40304

Yes, it's possible to include a second column within SUMMARIZE like this:

= SUMMARIZE( table1, table1[column], "COLUMN 2", <DAX Expression> )

Another way is to do this:

= ADDCOLUMNS( SUMMARIZE( table1, table1[column]), "COLUMN 2", <DAX Expression> )

For padding-left with zeros, try something like this:

Summary =
VAR Length = MAXX ( table1, LEN ( table1[column] ) )
RETURN
    SUMMARIZE (
        table1,
        table1[column],
        "COLUMN 2", REPT ( "0", Length - LEN ( table1[column] ) ) & table1[column]
    )

This prepends as many zeros as necessary to make the string the same length as the longest one in table[column].

Upvotes: 1

Related Questions