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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
wei
Frequent Visitor

Dynamic Column Calculation and Sum Based on slicer selector

HI, I tried so much and could not figure out, hope some one could help me!

 

I have a table with 4 columns:

Table: TableXYZ

idusergendervalue
1a110
2a25
3a110
4b01
5b21
6b15
7c16

 

What I want is with selecting different gender,

无标题.png

I could get a new measure 'sumvalue'  to sum value for every user, I also could 'rank' user according their sumvalue.  for example, if I select gender '1', I get:

usergendersumvaluerank
a1201
b153
c162

  

I hope I explained it sufficiently and there is someone who could help!! thanks a lot!

1 ACCEPTED SOLUTION
Eric_Zhang
Microsoft Employee
Microsoft Employee


@wei wrote:

Many thanks, Dog! I followed your suggestion and added measures and table visual, the result is as below. Seems SumofVaule is correct but Rank is not we wanted. More help needed!

无标题.png


@wei

This measure shall work.

Rank =
RANKX (
    ALLSELECTED ( TableXYZ ),
    CALCULATE (
        SUM ( TableXYZ[value] ),
        ALLEXCEPT ( TableXYZ, TableXYZ[user], TableXYZ[gender] )
    ),
    ,
    DESC,
    DENSE
)

Capture.PNGCapture1.PNG

 

View solution in original post

4 REPLIES 4
Dog
Responsive Resident
Responsive Resident

Hi,

 

assuming I'm understanding correctly it sounds like you just need to create two new measures. 

 

SumofValue:=SUM(value)

 

and

 

Rank:=RANKX(ALL(TableXYZ),[SumofValue],,DESC)

 

add table visual

add columns user and gender and measures SumofValue and Rank

 

then add a slicer onto page for gender.

 

does that help?

 

Dog

wei
Frequent Visitor

Many thanks, Dog! I followed your suggestion and added measures and table visual, the result is as below. Seems SumofVaule is correct but Rank is not we wanted. More help needed!

无标题.png

Eric_Zhang
Microsoft Employee
Microsoft Employee


@wei wrote:

Many thanks, Dog! I followed your suggestion and added measures and table visual, the result is as below. Seems SumofVaule is correct but Rank is not we wanted. More help needed!

无标题.png


@wei

This measure shall work.

Rank =
RANKX (
    ALLSELECTED ( TableXYZ ),
    CALCULATE (
        SUM ( TableXYZ[value] ),
        ALLEXCEPT ( TableXYZ, TableXYZ[user], TableXYZ[gender] )
    ),
    ,
    DESC,
    DENSE
)

Capture.PNGCapture1.PNG

 

Dog
Responsive Resident
Responsive Resident

Hi, 

 

Try

 

Rank:=RANKX(ALLSELECTED(TableXYZ),[SumofValue],,DESC)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.