Forum Discussion

luxpbi's avatar
luxpbi
Helper V
8 years ago

Problem with total row in matrix

Hi all, 

 

I have a Data that looks similar to this:

TypeAmountNumberAverage Price
A          1.000                  10                     100  
B          2.000                  10                     200  
C          3.000                  40                       75  
Total          6.000                  48                     125  

 

Amount is just a SUM. 

Average Price y just an Average.

Number is

DIVIDE(AMOUNT;AVERAGE PRICE;BLANK())

Like I wanted the total row Number represent the sum of the rows A, B and C and not the Division of Amount and Average Price, I did this: 

Number = IF(
    HASONEFILTER([Type]) ; DIVIDE([Amount] ; [Average Price] ; BLANK()) ; 
    SUMX (
            SUMMARIZE (
                VALUES ( [Type] );
                [Type];
                "AB"; DIVIDE ( [Amount]; [AVGPrice]; BLANK () )
            );
            [AB]
        ) 

And it works for that table. 

 

But the problem is when I want to represent the same data and measures but with a different dimension. 

Imagin that now I want to see it instead of by type, by Country, like this:

Country
Z
X
Y
Total


The measure won't work because just works in case that type is filtered ...

Any ideas to solve the problem that will work with all the dimensions of my model?

Thank you in advance!!

4 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    luxpbi

     

    Give this a shot

     

    Number =
    IF (
        HASONEFILTER ( [Type] ),
        DIVIDE ( [Amount], [Average Price], BLANK () ),
        SUMX (
            ALLSELECTED ( TABLENAME ),
            DIVIDE ( [Amount], [Average Price], BLANK () )
        )
    )
    • luxpbi's avatar
      luxpbi
      Helper V

      Zubair_Muhammad thanks for your answer but it doesn't work even with the [Type] table visual.

      And I think that your formula would work only with a table visual with the dimension [Type] and not with others. 

      • luxpbi's avatar
        luxpbi
        Helper V

        Anyone wit more ideas? It's really urgent for me. 
        If I don't find a solution I'll have to do a lot of different meassures, one for each dimension. And it's not efficient at all...