Greg_Deckler's avatar
Greg_Deckler
Icon for Community Champion rankCommunity Champion
2 years ago

XBITOR

It's BITOR but it iterates over any number of rows. Kind of spiffy in that it has 2 different "for" loops.

 

 

XBITOR = 
    VAR __RowCount = COUNTROWS('bitor')
    VAR __Length = LEN(MAX('bitor'[day_of_month_bit_position]))
    VAR __String = CONCATENATEX('bitor', [day_of_month_bit_position])
    VAR __Table = 
            ADDCOLUMNS(
                GENERATESERIES(0, __RowCount * __Length - 1),
                "__Bit", MID(__String, [Value]+1, 1) + 0,
                "__Mod", MOD([Value], __Length)
            )
    VAR __Table1 = 
        ADDCOLUMNS(
            GENERATESERIES(0, __Length - 1),
            "__BITOR", 
                    VAR __Index = [Value]
                    VAR __Sum = SUMX(FILTER(__Table, [__Mod] = __Index),[__Bit])
                    VAR __Result = IF(__Sum = 0, 0, 1)
                RETURN
                    __Result
        )
RETURN
    CONCATENATEX(__Table1, [__BITOR],,[Value],ASC)

 

 

 

 

 

No RepliesBe the first to reply