Forum Discussion

kaushikd's avatar
kaushikd
Icon for Resolver II rankResolver II
8 years ago
Solved

Difference (Accross Then Down)--DAX Formula

Hi Guys,

 

Here is my sample data:-

Col ACol BValue
Aa5
Ba1
Bb10
Cb1
Ca1
Cc15
Dd20
Ee25
Ff30
Gg35
Hh40
Ii45
Jj50
Kk55
Ll60
Ab7

 

When I draft it in power bi it looks like this:-

Now What I want is to find out Difference(Across row then Down By Column), So basicly the difference will be calculated left to right in a row, when row ends then it should not restart, rather take the value from previous row last column and continues the calculation. Below is the desired output.

 

 

8 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Out of blatant curiousity, what is the use case for this or is this just a mental excercise?

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        This strikes me as Tableau Troll, but sure, why not.

         

        Create this table "RowIndex":

        Row CharacterRow Index

        a1
        b2
        c3
        d4
        e5
        f6
        g7
        h8
        i9
        j10
        k11
        l12

         

         

        Now this table, "ColumnIndex":

         

         

         

        Column CharacterColumn Index

        A1
        B2
        C3
        D4
        E5
        F6
        G7
        H8
        I9
        J10
        K11
        L12

         

        Now this column in your table:

         

        Column = LOOKUPVALUE(RowIndex[Row Index],RowIndex[Row Character],[Col B]) * 10 + LOOKUPVALUE(ColumnIndex[Column Index],ColumnIndex[Column Character],[Col A])

        Now this:

         

        Column 2 = [Value]-MAXX(FILTER(Table1,Table1[Column]<EARLIER([Column])),[Value])

        Again, saying it's a Tableau thing doesn't explain the actual use case for this.