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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
charlineklapu
Frequent Visitor

Measure to find max values within categories using direct query

Hello,

 

I am trying to create a new measure, which gives me the max value per order number. 

 

The table I am working with looks as followed:

Table Name:Reaktionszeit     
       
Columns:AuftragsnummerReaktionszeit in TagenDatum (E)Datum (S)LandProduct
 11501.01.202205.01.2022CHgreen
 111001.01.202210.01.2022CHgreen
 22601.02.202206.02.2022DEblue
 33101.03.202202.03.2022BEred
 331001.03.202210.03.2022BEred
 332001.03.202220.03.2022BEred

 

and the desired result looks like this:

 

AuftragsnummerReaktionszeit in TagenDatum (E)Datum (S)LandProduct
111001.01.202210.01.2022CHgreen
22601.02.202206.02.2022DEblue
332001.03.202220.03.2022BEred

 

Important to mention is also that this model is working on direct query mode. Therefore the "normal" Dax formula doesn't work.

 

I look forard to hear from the dax experts on here, which are willing to help.

 

I appreciate it!

 

Have a great evening and best regards from Germany

Charline 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Picture1.png

 

Reaktionszeit in Tagen max =
VAR currentreakionszeit =
    SUM ( Reaktionszeit[Reaktionszeit in Tagen] )
RETURN
    IF (
        currentreakionszeit
            = SUMX (
                GROUPBY (
                    FILTER (
                        ALL ( Reaktionszeit ),
                        Reaktionszeit[Auftragsnummer] = MAX ( Reaktionszeit[Auftragsnummer] )
                    ),
                    Reaktionszeit[Auftragsnummer],
                    "@max", MAXX ( CURRENTGROUP (), Reaktionszeit[Reaktionszeit in Tagen] )
                ),
                [@max]
            ),
        currentreakionszeit,
        BLANK ()
    )

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

4 REPLIES 4
Syk
Super User
Super User

Should be just a max function.. Included a screenshot of your data (I edited headings but same data)

Measure = Max('Table'[Reaktionszeit in Tagen])

 

 

Syk_0-1646845075294.png

 

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Picture1.png

 

Reaktionszeit in Tagen max =
VAR currentreakionszeit =
    SUM ( Reaktionszeit[Reaktionszeit in Tagen] )
RETURN
    IF (
        currentreakionszeit
            = SUMX (
                GROUPBY (
                    FILTER (
                        ALL ( Reaktionszeit ),
                        Reaktionszeit[Auftragsnummer] = MAX ( Reaktionszeit[Auftragsnummer] )
                    ),
                    Reaktionszeit[Auftragsnummer],
                    "@max", MAXX ( CURRENTGROUP (), Reaktionszeit[Reaktionszeit in Tagen] )
                ),
                [@max]
            ),
        currentreakionszeit,
        BLANK ()
    )

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.

thank you, works perfectly!

Hi, @charlineklapu '

You can add a new measure like the following and apply it to the Visual Filters pane to filter your data.

Max_ Reaktionszeit in Tagen = 
CALCULATE (
    MAX ( 'Table'[Reaktionszeit in Tagen] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Auftragsnummer] = MAX ( 'Table'[Auftragsnummer] )
    )
)
flag = IF(SELECTEDVALUE('Table'[Reaktionszeit in Tagen])=[Max_ Reaktionszeit in Tagen],1,0)

21.png

 

Best Regards,
Community Support Team _ Eason

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.