Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

New column

Hi,
I have a table with different measures and columns, including columns account number, account group, and a measure called Totalsum. I want to add a column called Income with the following 4-row names.

 

Income
Group1          where account no is 3
Group2          where account no is 2 or 3 or 5, and account group is not 20
Group3          where account group is 20
All costs         Group1 + Group2 + Group3

so when I add the column Income and the measure Totalsum on the table visual, It should look like this

 

Income

Totalsum

Group1

1500

Group2

1000

Group3

1400

All costs

3900

 

Thanks in advance!

8 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Try using Grouping feature. Your total row will contain all costs.

    • Anonymous's avatar
      Anonymous
      Not applicable

       Hi Greg_Deckler 
      What I want to add are rows with the logic mentioned above.
      I used the following expression to create the column Income with the rows names Group1, Group2, and Group3, but I don't know how to get the row name All costs( it's the sum of the other three rows)

      Income=

      var g1 = account no=3 var g2 = account no= 2 || account no= 3 || account no = 5   && account group <> 20 var g3= account group = 20 return SWITCH(TRUE(),g1,"Group1",g2,"Group2",g3,"Group3")

       

      So How can I add the row name All costs in the above expression?

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Anonymous Use a disconnected table with your group names including the All costs group. Then you can create a measure like this:

        Measure = 
          VAR __Group = MAX('DisconnectedTable'[Column])
        RETURN
          SWITCH(__Group),
            "Group1", CALCULATE('Table'[Income]),'Table'[AccountNo] = 3,
            ...
          )