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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.