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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Toine40
Regular Visitor

Extract the whole line of a table containing the maximum value

Hi everyone, 
I have this table, in which each line represents a stop cause and the duration of each stop :

Toine40_0-1734173618084.png

I manage to create a table to sum the stop duration and group by stop cause with this formula : 

Tab_Cause_Arret_maxi =
SUMMARIZECOLUMNS
(
'Arrêts'[Date],'Arrêts'[Libellé Motif],
FILTER('Arrêts','Arrêts'[Type d'arrêt] IN {"ARE", "AI", "ANQ"} && 'Arrêts'[Atelier]="U2_M_DECOUPE"),
"Tps_maxi",SUM('Arrêts'[Temps (en min)])
)
Here's the result :

Toine40_1-1734173679717.png

What I would like now is to get only the first line, corresponding to the maximum stop cause 
I manage to get the max stop duration with this formula : 

CAUSE MAX = MAXX(Tab_Cause_Arret_maxi,Tab_Cause_Arret_maxi[Tps_maxi])


Toine40_2-1734173887891.png

But what I want is the whole line, sth like this, with the stopo cause and the duration :

Toine40_3-1734173960374.png


Can someone help ?
And maybe there's a way to get the result without creating this new table ?

Thanks to all of you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Toine40 

 

Please try this measure:

MEASURE =
VAR _Tab_Cause_Arret_maxi =
    SUMMARIZECOLUMNS (
        'Arrêts'[Date],
        'Arrêts'[Libellé Motif],
        FILTER (
            'Arrêts',
            'Arrêts'[Type d'arrêt]
                IN { "ARE", "AI", "ANQ" }
                    && 'Arrêts'[Atelier] = "U2_M_DECOUPE"
        ),
        "Tps_maxi", SUM ( 'Arrêts'[Temps (en min)] )
    )
RETURN
    CONCATENATEX (
        TOPN ( 1, _Tab_Cause_Arret_maxi, [Tps_maxi], 0 ),
        [Libellé Motif] & " " & [Tps_maxi]
    )

This measure creates a virtual table variable, so that you don't need to create an entity table anymore.

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Toine40 

 

Please try this measure:

MEASURE =
CONCATENATEX (
    TOPN ( 1, 'Tab_Cause_Arret_maxi', 'Tab_Cause_Arret_maxi'[Tps_maxi], 0 ),
    'Tab_Cause_Arret_maxi'[Libellé Motif] & " " & 'Tab_Cause_Arret_maxi'[Tps_maxi]
)

the result is as follow:

vzhengdxumsft_1-1734319126440.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thks a lot v-zhengdxu-msft, 

This works fine !!! I'd like we could mix both your answer and the one of DataNinja777 to avoid the creation of a new table, but if we can't you solution is th best. Thanks a lot for this
 
 
Anonymous
Not applicable

Hi @Toine40 

 

Please try this measure:

MEASURE =
VAR _Tab_Cause_Arret_maxi =
    SUMMARIZECOLUMNS (
        'Arrêts'[Date],
        'Arrêts'[Libellé Motif],
        FILTER (
            'Arrêts',
            'Arrêts'[Type d'arrêt]
                IN { "ARE", "AI", "ANQ" }
                    && 'Arrêts'[Atelier] = "U2_M_DECOUPE"
        ),
        "Tps_maxi", SUM ( 'Arrêts'[Temps (en min)] )
    )
RETURN
    CONCATENATEX (
        TOPN ( 1, _Tab_Cause_Arret_maxi, [Tps_maxi], 0 ),
        [Libellé Motif] & " " & [Tps_maxi]
    )

This measure creates a virtual table variable, so that you don't need to create an entity table anymore.

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is it !!!! Exactly ! Thank you so much @v-zhengdxu-msft 🙏🙏

DataNinja777
Super User
Super User

Hi @Toine40 ,

 

To get the maximum stop cause and its corresponding duration, you can achieve this either by creating a dynamic measure or by defining a calculated table, depending on your needs.

For a dynamic solution without creating a new table, you can write a measure that identifies the maximum stop duration and retrieves the associated stop cause. The measure can be defined as follows:

Max_Stop_Cause = 
VAR MaxDuration = 
    MAXX(
        FILTER(
            'Arrêts',
            'Arrêts'[Type d'arrêt] IN {"ARE", "AI", "ANQ"} &&
            'Arrêts'[Atelier] = "U2_M_DECOUPE"
        ),
        'Arrêts'[Temps (en min)]
    )
VAR MaxRow =
    TOPN(
        1,
        FILTER(
            'Arrêts',
            'Arrêts'[Type d'arrêt] IN {"ARE", "AI", "ANQ"} &&
            'Arrêts'[Atelier] = "U2_M_DECOUPE"
        ),
        'Arrêts'[Temps (en min)],
        DESC
    )
RETURN
    CONCATENATEX(
        MaxRow,
        'Arrêts'[Libellé Motif] & " - " & MaxDuration,
        ", "
    )

This measure dynamically calculates the maximum stop duration by filtering the relevant rows and creates a string combining the stop cause and the maximum duration. 

 

 

Best regards,

Hi @DataNinja777,
This looks so great, that's exactly what I need ! Only thing is the result is

Toine40_0-1734182286778.png

This is the second max cause and not the first one ; I've been trying to understand for more thant 1 hour but can't find the reason

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.