Reply
BIswajit_Das
Super User
Super User
Partially syndicated - Outbound

POWER BI DAX QUERY

Hello,

I have a table like
SLNORES1USERGROUP

1A1A
1B2A
1A3A
1A4A
1B5A
1A6A
1C7A
1A8A
2B9A
2B10A
2A11A
2B12A
2B13A
2A14A
2C15A
3C16A
3A17A
3C18A
3C19A
1A20B
1A21B
1C22B
1A23B

and I created a measure which calculate the max count value of USER , SLNO wise and GROUP Wise
i.e
ds.png

and i want to calculate the 2nd max value for each SLNO; GROUP Wise 
My Required table is like

GROUPSLNOT@MAX%VALT@MAX2%VAL
A152
B131
A242
A331

i want to use measures for the whole calculations 
and there should be slicers of group to check the result
Thanks & Regards...

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Syndicated - Outbound

Hi, @BIswajit_Das 

 

May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1703066346912.png

 

 

Measures:

MAXCOUNT =

VAR _max_count =

    MAXX (

        SUMMARIZE ( 'Table', 'Table'[RES1], "count", COUNTROWS ( 'Table' ) ),

        [count]

    )

RETURN

    _max_count



SECONDMAXCOUNT =
VAR _max_count =
    MAXX (
        SUMMARIZE ( 'Table', 'Table'[RES1], "count", COUNTROWS ( 'Table' ) ),
        [count]
    )
VAR _value =

    MAXX (
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[RES1], "@count", COUNTROWS ( 'Table' ) ),
            [@count] = _max_count
        ),
        'Table'[RES1]
    )
VAR _sec_max_count =
    MAXX (
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[RES1], "count2", COUNTROWS ( 'Table' ) ),
            'Table'[RES1] <> _value
        ),
        [count2]
    )
RETURN
    _sec_max_count

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
v-yaningy-msft
Community Support
Community Support

Syndicated - Outbound

Hi, @BIswajit_Das 

 

May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1703066346912.png

 

 

Measures:

MAXCOUNT =

VAR _max_count =

    MAXX (

        SUMMARIZE ( 'Table', 'Table'[RES1], "count", COUNTROWS ( 'Table' ) ),

        [count]

    )

RETURN

    _max_count



SECONDMAXCOUNT =
VAR _max_count =
    MAXX (
        SUMMARIZE ( 'Table', 'Table'[RES1], "count", COUNTROWS ( 'Table' ) ),
        [count]
    )
VAR _value =

    MAXX (
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[RES1], "@count", COUNTROWS ( 'Table' ) ),
            [@count] = _max_count
        ),
        'Table'[RES1]
    )
VAR _sec_max_count =
    MAXX (
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[RES1], "count2", COUNTROWS ( 'Table' ) ),
            'Table'[RES1] <> _value
        ),
        [count2]
    )
RETURN
    _sec_max_count

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)