Forum Discussion

Fragan's avatar
Fragan
Icon for Helper III rankHelper III
6 years ago
Solved

Row Sub Total equals is calculated

Hey,

 

I have this table :

 

And i want to calculate foreach day and foreach group 1and2 % wich is (Attribute1/Attribute2)*100

And i want to include `1and2 %` in Group Subtotal and on total

I created a new table :

I created a new table :

Table3 = UNION(DISTINCT('Table'[Attributes]);{{"1and2 %"}})

And i made this mesure to calculate 1and2 %:

Measure = 
SUMX (
    DISTINCT ( 'Table3'[Attributes] );
    SWITCH (
        'Table3'[Attributes];
        "1and2 %"; IFERROR((CALCULATE ( SUM ( 'Table'[Value] ); 'Table'[Attributes] = "Attribute1" )
            / CALCULATE ( SUM ( 'Table'[Value] ); 'Table'[Attributes] = "Attribute2" ))*100;0);
            var a = 'Table3'[Attributes] return
        CALCULATE ( SUM ( 'Table'[Value] );'Table'[Attributes]=a)
    )
)

And this is the result im getting :

 

I want to exclude 1and2 % (and every Attribute containing % in the future) from group subtotal and the total.

Im really new to PowerBI and not really familiar with Excel like formulas.. Can anyone please help me up with that ?

Regards

 

  • OK, taking a look back at the original post, perhaps something like:

     

    Measure 2 =
    VAR __Table =
      ADDCOLUMNS(
        SUMMARIZE(
          'Table 3',
          [Group],
          [Attribute],
          "__Measure",[Measure]
        ),
        "__IncludeInTotals",SEARCH("%",[Attribute],,-1)
      )
    RETURN
      IF(
        HASONEVALUE('Table 3'[Attribute]),
        [Measure],
        SUMX(FILTER(__Table,[__IncludeInTotals] = -1),[__Measure])
      )

13 Replies