Greg_Deckler
Community Champion
2 years agoXBITXOR
It's BITXOR but for multiple rows.
XBITXOR =
VAR __RowCount = COUNTROWS('bitor')
VAR __Length = LEN(MAX('bitor'[day_of_month_bit_position]))
VAR __String = CONCATENATEX('bitor', [...
AlexisOlson
Super User
2 years agoGreg_Deckler I think you're a bit off somewhere. For example, shouldn't customer_3, month 1 have 1 as the last digit?
Here's my attempt:
XBITOR =
VAR _BitStrings_ = DISTINCT ( 'bitor'[day_of_month_bit_position] )
VAR _Length = MAXX ( _BitStrings_, LEN ( 'bitor'[day_of_month_bit_position] ) )
VAR _BITOR_ =
ADDCOLUMNS (
GENERATESERIES ( 1, _Length ),
"@Bit",
MAXX (
_BitStrings_,
MID ( 'bitor'[day_of_month_bit_position], [Value], 1 )
)
)
VAR _ToString = CONCATENATEX ( _BITOR_, [@Bit], "", [Value] )
RETURN
_ToStringAlexisOlson
Super User
2 years agoIf the bit strings are not all the same length, then you probably want to left pad with zeros like this:
XBITOR =
VAR _BitStrings_ =
SELECTCOLUMNS (
DISTINCT ( 'bitor'[Pos] ),
"@BitStr", 'bitor'[Pos]
)
VAR _Length = MAXX ( ALLSELECTED ( 'bitor' ), LEN ( 'bitor'[Pos] ) )
VAR _Padded_ =
ADDCOLUMNS (
_BitStrings_,
"@Padded", REPT ( "0", _Length - LEN ( [@BitStr] ) ) & [@BitStr]
)
VAR _BITOR_ =
ADDCOLUMNS (
GENERATESERIES ( 1, _Length ),
"@Bit", MAXX ( _Padded_, MID ( [@Padded], [Value], 1 ) )
)
VAR _ToString = CONCATENATEX ( _BITOR_, [@Bit], "", [Value] )
RETURN
_ToString- Greg_Deckler2 years ago
Community Champion
AlexisOlson I like the idea of padding for instances of having different lengths of bits.