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

Max of Column A based on slicer filter of Column A

I have a Calculation as below

Calaculate(MAX(columna),all(table))

 

I want to get max value in columna based on slicer on columna, if I uncheck max value in columna slicer, above calculation should return 2nd max value.

In Tableau when we add filter to context, this is acheived.

1 ACCEPTED SOLUTION
v-venuppu
Community Support
Community Support

Hi @Anonymous ,

Thank you for reaching out to Microsoft Fabric Community.

You can try below DAX to solve the issue:

SecondMaxOrSelected =
VAR IsFilteredCol = ISFILTERED('Data'[columna])
VAR SelectedValues = VALUES('Data'[columna])
VAR SelectedCount = COUNTROWS(SelectedValues)

RETURN
IF(
IsFilteredCol,
IF(SelectedCount = 1, MAX('Data'[columna]), BLANK()),
CALCULATE(
MAX('Data'[columna]),
TOPN(
1,
FILTER(
ALL('Data'[columna]),
'Data'[columna] < CALCULATE(MAX('Data'[columna]), ALL('Data'))
),
'Data'[columna], DESC
)
)
)

Make sure to replace 'Data' with your TableName.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

Thank you.

View solution in original post

5 REPLIES 5
v-venuppu
Community Support
Community Support

Hi @Anonymous ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Anonymous ,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Anonymous ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

v-venuppu
Community Support
Community Support

Hi @Anonymous ,

Thank you for reaching out to Microsoft Fabric Community.

You can try below DAX to solve the issue:

SecondMaxOrSelected =
VAR IsFilteredCol = ISFILTERED('Data'[columna])
VAR SelectedValues = VALUES('Data'[columna])
VAR SelectedCount = COUNTROWS(SelectedValues)

RETURN
IF(
IsFilteredCol,
IF(SelectedCount = 1, MAX('Data'[columna]), BLANK()),
CALCULATE(
MAX('Data'[columna]),
TOPN(
1,
FILTER(
ALL('Data'[columna]),
'Data'[columna] < CALCULATE(MAX('Data'[columna]), ALL('Data'))
),
'Data'[columna], DESC
)
)
)

Make sure to replace 'Data' with your TableName.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

Thank you.

ribisht17
Super User
Super User

HI @Anonymous 

 

Try this 

 

MaxValue = CALCULATE(MAX('Table'[columna]), ALLSELECTED('Table'[Column]))

 

Also, with Tableau we use Context filter in the TOP N scenarios, not sure about your case

 

Regards,

Regards,

Ritesh

Community Champion

Please mark the answer if helpful so that it can help others

Dance-Sing with Data

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors