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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
BHAVIKCHAWLA
New Member

Understanding DAX

I am little new to Power BI and am finding little difficulty in understanding some concepts.
I was working - Highlighting max bars.
I am applied this logic - 

Maximum Value =
                Var MaxVal = MAXX(ALLEXCEPT(table,sum(column))
                 VAR Color = IF(sum(column) = MaxVal, "Dark Blue" , "Grey" )
                 RETURN Color
This gave me incorrect - actually all were dark blue.
Whereas if I create another measure total = sum(column) and replace like below
Maximum Value =
                Var MaxVal = MAXX(ALLEXCEPT(table,total)
                 VAR Color = IF(total= MaxVal, "Dark Blue" , "Grey" )
                 RETURN Color
This gave me correct.
Can someone please help me in understanding concept. If any video is there related to this concept, please share
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but please try something like below.

I think it needs context transition in the measure.

 

Maximum Value =
VAR MaxVal =
    MAXX ( ALL ( 'table' ), CALCULATE ( SUM ( 'table'[column] ) ) ) //need context transition and CALCULATE function enables context transition
VAR Color =
    IF ( SUM ( 'table'[column] ) = MaxVal, "Dark Blue", "Grey" )
RETURN
    Color

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @BHAVIKCHAWLA ,

 

Thanks @Jihwan_Kim  for sharing, I have an addition here:

Allexcept() function:
1. Removes all context filters in the table except filters that have been applied to the specified columns.

2. Functions for grouping

 

Here are other function recommendations you might consider using the all() and allselected() functions:

All():

Returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. This function is useful for clearing filters and creating calculations on all the rows in a table.

ALL function (DAX) - DAX | Microsoft Learn

Allselected():

Removes context filters from columns and rows in the current query, while retaining all other context filters or explicit filters.

ALLSELECTED function (DAX) - DAX | Microsoft Learn

 

If you want to find the maximum value of each grouping after removing all filters, you can try the following dax:

Measure =
MAXX(FILTER(ALL('Table'),'Table'[column]=MAX('Table'[column])),[Value])

If you want to find the maximum value of each grouping as Visual changes, you can try the following dax:

Group_Allselect =
MAXX(FILTER(ALLSELECTED('Table'),'Table'[column]=MAX('Table'[column])),[Value])


If you want to find the maximum value for the whole table after removing all filters, you can try the following dax:

Max_All =
MAXX(ALL('Table'),'Table'[Value])

If you want to find the maximum value for the whole table as Visual changes, you can try the following dax:

Max_Allselected =
MAXX(ALLSELECTED('Table'),'Table'[Value])

 

This is the data from the original table:

vyangliumsft_0-1711334185398.png

This is the result of measure:

vyangliumsft_1-1711334185401.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.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but please try something like below.

I think it needs context transition in the measure.

 

Maximum Value =
VAR MaxVal =
    MAXX ( ALL ( 'table' ), CALCULATE ( SUM ( 'table'[column] ) ) ) //need context transition and CALCULATE function enables context transition
VAR Color =
    IF ( SUM ( 'table'[column] ) = MaxVal, "Dark Blue", "Grey" )
RETURN
    Color

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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