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
Arjun_reddy
Helper I
Helper I

dax query

Hi Community team,

 

I need you help on build dax query for second largest retail channel on total sales
I am sharing the code for first largest retail channel  on total sales 

1largest_TotalChannel =
VAR MaxTotal = MAX(Tostitos_MP[TOTAL OCCASIONS])
VAR Maxyear=MAX(Tostitos_MP[YEAR])
VAR CHANNEL_OCC=
    CALCULATE(
        VALUES(Tostitos_MP[RETAIL CHANNEL]),
        Tostitos_MP[TOTAL OCCASIONS] = MaxTotal,Tostitos_MP[YEAR]=Maxyear
    )
    RETURN
    CHANNEL_OCC

Please check the code and modify for second largest retail channel on total occasions 

Thanks,
Arjun Reddy
1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26RihMKgrmog1QqoECj?e=OQNfR6

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

View solution in original post

9 REPLIES 9
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26RihMKgrmog1QqoECj?e=OQNfR6

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Ahmedx
Super User
Super User

Share sample pbix file to help you.

Please find the below data table

categoryyearsales
chairs20215000
tables20216000
bulbs20226000
sofa20224500
chairs20228000
chairs20216000
chairs20212800
sofa20224700
bulbs20222000
sofa20215500
tables20216000
tables20223400
bulbs20214000

you can show what result you expect

Arjun_reddy_0-1692252664941.png

result should be have as mentioned rounded yellow color in snap

Is this what you are looking for?

Screenshot_1.png

or this&

Screenshot_2.png

Hi  Ahmedx,

 

not that solution, my query is i want to get the category on which is the second highest sales in category on max year, In the data , chairs is having second highest sales, please write the query on my concern.
result should get as: chairs contributed with sales value

Hi Ahmedx,

 

I am unable to add power bi and excel file, please find the below attachment.

 

Arjun_reddy_0-1692199484475.png

 

Thanks,

Arjun Reddy.

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