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! Learn more

Reply
rahulmmenon
New Member

How to retrieve data of one column based on another Numeric column in the same table?

Hi Team,

 

I have 4 problems (sample dataset for the senario is also given below.

 

1. I want to get the name of Category based on the total sale made in a card visual.

2. I want to get the name of Category based on the Highest count of sales (number of transaction) in a card visual.

3. I want to get the name of Sub category  based on the highest sale.

4. I want to get the name of Sub category based on the Highest count of sales (number of transaction) 

 

rahulmmenon_0-1673976183906.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rahulmmenon ,

 

1. Get the name of Category based on the total sale maximum in a card visual.

sum group by category =
CALCULATE (
    SUM ( 'Table'[Sales] ),
    FILTER ( ALLSELECTED ( 'Table' ), [Category] = MAX ( 'Table'[Category] ) )
)
Category based on the total sale maximum =
CALCULATE (
    MAX ( 'Table'[Category] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [sum group by category]
            = MAXX ( ALLSELECTED ( 'Table' ), [sum group by category] )
    )
)

vstephenmsft_0-1674023224250.png

2.Get the name of Category based on the Highest count of sales. The measure returns an aggregate value, and if there are categories with the same highest count, since I used MAX, it will return Mobile in alphabetical order of the categories. 

Count group by category =
CALCULATE (
    COUNT ( 'Table'[Sales] ),
    FILTER ( ALLSELECTED ( 'Table' ), [Category] = MAX ( 'Table'[Category] ) )
)
Category based on the Highest count of sales =
CALCULATE (
    MAX ( 'Table'[Category] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Count group by category]
            = MAXX ( ALLSELECTED ( 'Table' ), [Count group by category] )
    )
)

vstephenmsft_3-1674024536145.png

You can create the following measure to get the correct categories. Card visuals will only return an aggregated value, which is recommended to be viewed in a table visual.

Hiest Count Category =
IF (
    MAXX ( ALLSELECTED ( 'Table' ), [Count group by category] ) = [Count group by category],
    MAX ( 'Table'[Category] )
)

7.png

3.Get the name of Sub category  based on the highest sale.

Sub category  based on the highest sale = 
CALCULATE (
    MAX ( 'Table'[Sub category] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Sales] = MAXX ( ALLSELECTED ( 'Table' ), [Sales] )
    )
)

vstephenmsft_1-1674023604937.png

For you last question, what's the expected result? I think the count of sales based on each sub category is 1.

 

Best Regards,

Stephen Tao

 

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 @rahulmmenon ,

 

1. Get the name of Category based on the total sale maximum in a card visual.

sum group by category =
CALCULATE (
    SUM ( 'Table'[Sales] ),
    FILTER ( ALLSELECTED ( 'Table' ), [Category] = MAX ( 'Table'[Category] ) )
)
Category based on the total sale maximum =
CALCULATE (
    MAX ( 'Table'[Category] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [sum group by category]
            = MAXX ( ALLSELECTED ( 'Table' ), [sum group by category] )
    )
)

vstephenmsft_0-1674023224250.png

2.Get the name of Category based on the Highest count of sales. The measure returns an aggregate value, and if there are categories with the same highest count, since I used MAX, it will return Mobile in alphabetical order of the categories. 

Count group by category =
CALCULATE (
    COUNT ( 'Table'[Sales] ),
    FILTER ( ALLSELECTED ( 'Table' ), [Category] = MAX ( 'Table'[Category] ) )
)
Category based on the Highest count of sales =
CALCULATE (
    MAX ( 'Table'[Category] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Count group by category]
            = MAXX ( ALLSELECTED ( 'Table' ), [Count group by category] )
    )
)

vstephenmsft_3-1674024536145.png

You can create the following measure to get the correct categories. Card visuals will only return an aggregated value, which is recommended to be viewed in a table visual.

Hiest Count Category =
IF (
    MAXX ( ALLSELECTED ( 'Table' ), [Count group by category] ) = [Count group by category],
    MAX ( 'Table'[Category] )
)

7.png

3.Get the name of Sub category  based on the highest sale.

Sub category  based on the highest sale = 
CALCULATE (
    MAX ( 'Table'[Sub category] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Sales] = MAXX ( ALLSELECTED ( 'Table' ), [Sales] )
    )
)

vstephenmsft_1-1674023604937.png

For you last question, what's the expected result? I think the count of sales based on each sub category is 1.

 

Best Regards,

Stephen Tao

 

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