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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Score Card with Dynamic Ranking

Hi Everyone.

I have an issue with score card and column charts where i need the dynamic ranking.
I have a category column with 16 distinct values in it and few other columns which im using as filters. Lets say 5 filters im using.
I need to Show the Category name in one scorecard and its percentage value in another score card and its last 6 months cloumn trend to its side.
Similarly i need to keep for 16 category values.
I need the dynamic ranking for it. 
I tried creating the dynamic ranking in measure. but it was not working. im getting all the values as "1"
I need to display all 16 rows  of two scorecard and a chart, in accending order of percentage value. that why i need a ranking. Based on the slicer selections the rank should change.
Lets say if i select one slicer value and it has onlt 5 categories, only i need to show the top 5 rows and remaining rows of score cards and graph should be empty. 
Im able to crack this by creating static ranking by creating a calculated table.But thats not the requriment.
Kindly help me with some ideas.
Thanks it advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1728959820698.png

 

Here are the steps you can follow:

1. Create measure.

category Name =
VAR _group1 =
    SELECTEDVALUE ( 'Table'[Group1] )
VAR _group2 =
    SELECTCOLUMNS ( 'Table', "test", 'Table'[Group2] )
VAR _table =
    FILTER (
        ALL ( 'Table' ),
        'Table'[Group1] = _group1
            && 'Table'[Group2] IN _group2
    )
VAR _table2 =
    SUMMARIZE ( _table, [Category] )
RETURN
    CONCATENATEX ( _table2, [Category], "-" )
category percentage =
VAR _group1 =
    SELECTEDVALUE ( 'Table'[Group1] )
VAR _group2 =
    SELECTCOLUMNS ( 'Table', "test", 'Table'[Group2] )
VAR _today =
    TODAY ()
VAR _last6month =
    DATE ( YEAR ( _today ), MONTH ( _today ) - 6, DAY ( _today ) )
VAR _table =
    FILTER (
        ALL ( 'Table' ),
        'Table'[Group1] = _group1
            && 'Table'[Group2] IN _group2
    )
VAR _table2 =
    ADDCOLUMNS (
        _table,
        "test1",
            [Category] & "-"
                & ROUND (
                    SUMX (
                        FILTER (
                            _table,
                            [Category] = EARLIER ( [Category] )
                                && [Group1] = EARLIER ( [Group1] )
                                && [Group2] = EARLIER ( [Group2] )
                                && [Date] >= _last6month
                                && [Date] <= _today
                        ),
                        [Value]
                    )
                        / SUMX (
                            FILTER (
                                _table,
                                [Category] = EARLIER ( [Category] )
                                    && [Group1] = EARLIER ( [Group1] )
                            ),
                            [Value]
                        ),
                    2
                )
    )
VAR _table3 =
    SUMMARIZE ( _table2, [Category], [test1] )
RETURN
    CONCATENATEX (
        FILTER ( _table3, [Category] <= MAX ( [Category] ) ),
        [test1],
        "/"
    )
category rank =
VAR _group1 =
    SELECTEDVALUE ( 'Table'[Group1] )
VAR _group2 =
    SELECTCOLUMNS ( 'Table', "test", 'Table'[Group2] )
VAR _today =
    TODAY ()
VAR _last6month =
    DATE ( YEAR ( _today ), MONTH ( _today ) - 6, DAY ( _today ) )
VAR _table =
    FILTER (
        ALL ( 'Table' ),
        'Table'[Group1] = _group1
            && 'Table'[Group2] IN _group2
    )
VAR _table2 =
    ADDCOLUMNS (
        _table,
        "test1",
            ROUND (
                SUMX (
                    FILTER (
                        _table,
                        [Category] = EARLIER ( [Category] )
                            && [Group1] = EARLIER ( [Group1] )
                            && [Group2] = EARLIER ( [Group2] )
                            && [Date] >= _last6month
                            && [Date] <= _today
                    ),
                    [Value]
                )
                    / SUMX (
                        FILTER (
                            _table,
                            [Category] = EARLIER ( [Category] )
                                && [Group1] = EARLIER ( [Group1] )
                        ),
                        [Value]
                    ),
                2
            )
    )
VAR _table3 =
    ADDCOLUMNS ( _table2, "rank", RANKX ( _table2, [test1],, DESC, DENSE ) )
RETURN
    MAXX ( FILTER ( _table3, [Category] = MAX ( 'Table'[Category] ) ), [rank] )

2. Result:

vyangliumsft_1-1728959820702.png

 

 

Best Regards,

Liu Yang

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

1 REPLY 1
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1728959820698.png

 

Here are the steps you can follow:

1. Create measure.

category Name =
VAR _group1 =
    SELECTEDVALUE ( 'Table'[Group1] )
VAR _group2 =
    SELECTCOLUMNS ( 'Table', "test", 'Table'[Group2] )
VAR _table =
    FILTER (
        ALL ( 'Table' ),
        'Table'[Group1] = _group1
            && 'Table'[Group2] IN _group2
    )
VAR _table2 =
    SUMMARIZE ( _table, [Category] )
RETURN
    CONCATENATEX ( _table2, [Category], "-" )
category percentage =
VAR _group1 =
    SELECTEDVALUE ( 'Table'[Group1] )
VAR _group2 =
    SELECTCOLUMNS ( 'Table', "test", 'Table'[Group2] )
VAR _today =
    TODAY ()
VAR _last6month =
    DATE ( YEAR ( _today ), MONTH ( _today ) - 6, DAY ( _today ) )
VAR _table =
    FILTER (
        ALL ( 'Table' ),
        'Table'[Group1] = _group1
            && 'Table'[Group2] IN _group2
    )
VAR _table2 =
    ADDCOLUMNS (
        _table,
        "test1",
            [Category] & "-"
                & ROUND (
                    SUMX (
                        FILTER (
                            _table,
                            [Category] = EARLIER ( [Category] )
                                && [Group1] = EARLIER ( [Group1] )
                                && [Group2] = EARLIER ( [Group2] )
                                && [Date] >= _last6month
                                && [Date] <= _today
                        ),
                        [Value]
                    )
                        / SUMX (
                            FILTER (
                                _table,
                                [Category] = EARLIER ( [Category] )
                                    && [Group1] = EARLIER ( [Group1] )
                            ),
                            [Value]
                        ),
                    2
                )
    )
VAR _table3 =
    SUMMARIZE ( _table2, [Category], [test1] )
RETURN
    CONCATENATEX (
        FILTER ( _table3, [Category] <= MAX ( [Category] ) ),
        [test1],
        "/"
    )
category rank =
VAR _group1 =
    SELECTEDVALUE ( 'Table'[Group1] )
VAR _group2 =
    SELECTCOLUMNS ( 'Table', "test", 'Table'[Group2] )
VAR _today =
    TODAY ()
VAR _last6month =
    DATE ( YEAR ( _today ), MONTH ( _today ) - 6, DAY ( _today ) )
VAR _table =
    FILTER (
        ALL ( 'Table' ),
        'Table'[Group1] = _group1
            && 'Table'[Group2] IN _group2
    )
VAR _table2 =
    ADDCOLUMNS (
        _table,
        "test1",
            ROUND (
                SUMX (
                    FILTER (
                        _table,
                        [Category] = EARLIER ( [Category] )
                            && [Group1] = EARLIER ( [Group1] )
                            && [Group2] = EARLIER ( [Group2] )
                            && [Date] >= _last6month
                            && [Date] <= _today
                    ),
                    [Value]
                )
                    / SUMX (
                        FILTER (
                            _table,
                            [Category] = EARLIER ( [Category] )
                                && [Group1] = EARLIER ( [Group1] )
                        ),
                        [Value]
                    ),
                2
            )
    )
VAR _table3 =
    ADDCOLUMNS ( _table2, "rank", RANKX ( _table2, [test1],, DESC, DENSE ) )
RETURN
    MAXX ( FILTER ( _table3, [Category] = MAX ( 'Table'[Category] ) ), [rank] )

2. Result:

vyangliumsft_1-1728959820702.png

 

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors