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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
claxxx
Frequent Visitor

Calculate MAX with dynamic dimension in Field Parameters

Hello, 

I have a table where I have my dimension which is dependent from a field parameter and my sales. The user can select one or various dimension in the field parameter; 

As a second mesure in the table I want to calculated the Max of my Sales. If nothing is selected like in my example below I should have "1746" as a Maximum Sales : 

claxxx_1-1705420379369.png

 

But If I select as a dynamic dimension "Country" then the Max sales should be "3214"

claxxx_2-1705420429353.png

I precise that I want this mesure "MAX SALES" to be in my table. So In the example above I Should have for the 3 lines the repetition of 3214. 

 

I've tried this DAX Formula : 

Max Sales_dynamic = CALCULATE(MAXX(ALLSELECTED('Dynamic Dimension'[Dynamic Dimension]),[SALES.]),ALLSELECTED('Dynamic Dimension'[Dynamic Dimension]))
 
but when I put it in the table i have the following message: "la colonne fait partie d'une clé composite, mais certaines colonnes de la clé composite ne sont pas incluses dans l'expression ou son expression dépendante*
 
thank you for your help 
here is the link of my pbi template https://we.tl/t-mGAXX5IsFr 
2 REPLIES 2
Anonymous
Not applicable

Hi @claxxx ,

Please try to change your measure with below dax formula:

Max Sales_dynamic =
VAR SelectedDimension =
    SELECTEDVALUE ( 'Dynamic Dimension'[Dynamic Dimension], "All" )
VAR MaxSales =
    CALCULATE ( MAX ( 'Sales'[SalesAmount] ), ALLSELECTED ( 'Sales' ) )
RETURN
    IF (
        SelectedDimension = "All",
        MaxSales,
        MAXX (
            FILTER (
                ALLSELECTED ( 'Sales' ),
                'Sales'[Dynamic Dimension] = SelectedDimension
            ),
            [SalesAmount]
        )
    )

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello , Thank you for your answer. 

In my case the measure Sales is in a table named "MESURES" where I stock all my measures. Should I refer to this table? 

In your formula I don't understand what 

'Sales'[Dynamic Dimension] 

refers to ? Because my Dynamic Dimension is just in my table

 'Dynamic Dimension'

created by the field parameters .

 

Other point, If the user select 2 fields how can I manage it in the dax formula

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors