Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
SoufTC
Helper I
Helper I

Subtotals in Matrix with Hierarchy not adding up

I’m having trouble to sum totals of subcategory

 

I have two tables.

1. A table that defines unique FaceBook pages names (repository)[Page] and the name of the person responsible for the page(repository)[RESP CONTENT]

 

repository

 

|   Page       |  RESP CONTENT |
---------------------------------
|   P1          |      RESP1             |
|   P2          |      RESP1             |
|   P3          |      RESP2             |
|   P4          |      RESP2             |
|   P5          |      RESP3             |
|   P6          |      RESP5             |
|   P7          |      RESP5             |
|   P8          |      RESP5             |
|   ....           |         .....               |

 

2. A table of the number of likes(FaceBook)[Likes] and followers(FaceBook)[Followers] per week (FaceBook)[Date]. The join with the (repository)table is done with the (FaceBook)[Page]

 

FaceBook

 

|   Page       |  Likes      |   Followers    |  Date          |

------------------------------------------------------

 | P1            |      32     |         50        |   2021-02-02

 | P1            |      40     |         60        |   2021-02-09

 | P1            |      70     |         100      |   2021-02-16

 | P2            |      80     |        150       |   2021-02-02

 | P2            |      90     |         250      |   2021-02-09

 | P2            |      150   |         350      |   2021-02-16

 | P3            |      10     |         50        |   2021-02-02

 | P3            |      32     |         50        |   2021-02-09

 | P3            |     50      |         80        |   2021-02-16

 

 

What I am expecting for [Community] are results like:

RESP CONTENT      Last Likes            Last Followers      Likes Rank      Followers Rank
               Community
-  RESP1        220              450              5
      P1       70            100        2           2           2
      P2     150            350        3            3            3
-  RESP2     50            80                1
     P3      50            80    1         1              1
           ...     ....           .............      .....
Total    270           490            6

 

With :

Last Likes =
CALCULATE (
SUM ( FaceBook[Likes] ),
LASTNONBLANK ( FaceBook[Date], SUM ( FaceBook[Likes] ) )
)
 
Last Followers =
CALCULATE (
SUM ( FaceBook[Followers] ),
LASTNONBLANK ( FaceBook[Date], SUM ( FaceBook[Followers] ) )
)
 
COMMUNITY = IF(
COUNTROWS(VALUES(repository[Page]))=1,
DIVIDE([Likes Rank] + [Followers Rank],2),
SUMX(repository[Page], DIVIDE([Likes Rank] + [Followers Rank],2))
)

 

for community measure SUMX can't give me the right result !!

I try :

SUMX(values(repository[Page]), DIVIDE([Likes Rank] + [Followers Rank],2))

SUMX(allselected(repository[Page]), DIVIDE([Likes Rank] + [Followers Rank],2))

 

nothing works!

 

Please, any help?

Thank's in advance

1 ACCEPTED SOLUTION

Hi, @SoufTC 

Try measures as follows:

Likes Rank = 
var _t=FIlter(ALL('repository'),[Last Likes]<>BLANK())
var _rank=
RANKX(_t,
    CALCULATE([Last Likes]),,ASC,Dense)
    return IF([Last Likes]<>BLANK()&&HASONEVALUE(repository[Page]),_rank)
Followers Rank = 
var _t=FIlter(ALL('repository'),[Last Followers]<>BLANK())
var _rank=
RANKX(_t,
    CALCULATE([Last Followers]),,ASC,Dense)
    return IF([Last Followers]<>BLANK()&&HASONEVALUE(repository[Page]),_rank)
COMMUNITY = 
SUMX(ADDCOLUMNS('repository',"_last rank",[Likes Rank],"_followers rank",[Followers Rank]),DIVIDE([_last rank]+[_followers rank],2))

Result:

vangzhengmsft_0-1646296247644.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
v-angzheng-msft
Community Support
Community Support

Hi, @SoufTC 

From what I've got, the last follow on P3 should be 80.

vangzhengmsft_0-1646273827061.png

Based on the information above, I create the community measure easily as follows:

COMMUNITY = 
([Last Followers]+[Last Likes])/2

this seems to work fine.

Result:

vangzhengmsft_1-1646273951439.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-angzheng-msft  thank you for your help ! but I made a mistake in the results table (I corrected it) I'm trying to calculate [community] using the rank like this : COMMUNITY = ([Likes Rank] + [Followers Rank])/2 ; but unfortunately I can't get the right total 

Hi, @SoufTC 

Try measures as follows:

Likes Rank = 
var _t=FIlter(ALL('repository'),[Last Likes]<>BLANK())
var _rank=
RANKX(_t,
    CALCULATE([Last Likes]),,ASC,Dense)
    return IF([Last Likes]<>BLANK()&&HASONEVALUE(repository[Page]),_rank)
Followers Rank = 
var _t=FIlter(ALL('repository'),[Last Followers]<>BLANK())
var _rank=
RANKX(_t,
    CALCULATE([Last Followers]),,ASC,Dense)
    return IF([Last Followers]<>BLANK()&&HASONEVALUE(repository[Page]),_rank)
COMMUNITY = 
SUMX(ADDCOLUMNS('repository',"_last rank",[Likes Rank],"_followers rank",[Followers Rank]),DIVIDE([_last rank]+[_followers rank],2))

Result:

vangzhengmsft_0-1646296247644.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-angzheng-msft this is exactly what I am looking for thank you !

PaulDBrown
Community Champion
Community Champion

at is the code for [Community] & [Evolution])?

 

You could try the following measure:

CM = SUMX(Table1, [Score])

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrownthank you but that's not what I need at all !

It would actually help if you provided sample non-confidential data (not images - we can't work on images...) and a depiction of the expected result.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown i just changed everything tell me if it is clear enough thank you in advance for your help 

I just changed my post thanks

You could try the following measure:

CM = SUMX(Table1, [Score])





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

What is the code for [score]?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.