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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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 is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors