Forum Discussion

leila675's avatar
leila675
New Member
1 year ago
Solved

Adding a new row to matrix

Hi there    I am hoping someone can help me.  I have spent far too many hours trying to figure this out.  I am relatively new to Dax but quite familiar with power query and pbi.  That said I have a...
  • rajendraongole1's avatar
    1 year ago

    Hi leila675  - Create a disconnected table for row labels

     

    GroupList =
    DATATABLE("Group", STRING, {
    {"Group A"},
    {"Group B"},
    {"Group C"},
    {"Variance"}
    })

     

     

     

    create a measure for totals to return Total2

    NewTotal =
    VAR SelectedGroup = SELECTEDVALUE(GroupList[Group])
    RETURN
    SWITCH(
    TRUE(),
    SelectedGroup = "Group A", CALCULATE(SUM(Table2[Value]), Table2[Group] = "Group A"),
    SelectedGroup = "Group B", CALCULATE(SUM(Table2[Value]), Table2[Group] = "Group B"),
    SelectedGroup = "Group C", CALCULATE(SUM(Table2[Value]), Table2[Group] = "Group C"),
    SelectedGroup = "Variance",
    CALCULATE(SUM(Table1[Value])) - CALCULATE(SUM(Table2[Value])),
    BLANK()
    )

     

    now place new total at values , Power BI will auto-calculate the Grand Total row (i.e., 47). Hope this works.