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
antoinersw
Regular Visitor

sum of the average sum

hello, I have the followind data : 

 

ClientNuméro_€ Projeté et signésheures_total_prestaDuree prestaheures_quantity_Heures projetés signéprix_heure_HT_unitaire_avec_remisemontant_HT_avec_remise
98457057DE230034418513671330122335.5543366
98457057DE230034519173671330122335.5563486
98457057DE230005213689.6466.133333333333436876233.0666666666667582232
98457057DE230005313014.933333333334466.133333333333436876233.0666666666667562122
98310560DD23002695637.517616532176331025
98310560DD23000635152.166666666666164.666666666666669552164.66666666666666311627
98310560DD23000644563.166666666666164.666666666666669552164.66666666666666271441
98310560DD23002703056.6108.810232108.829899

 

I need the following result : 

antoinersw_0-1674582117381.png

 

I tried the following formula

 

 

 

var e = 
sumx(
    values('leads'[Client]),
        AVERAGEX(
            leads,
                CALCULATE( 
                    sumx(
                        FILTER(
                             leads, 
                                 'leads'[heures_total_presta] = max('leads'[heures_total_presta]))
                                    , leads[Duree presta]/30 * 'leads'[montant_HT_avec_remise]),
                                        'leads'[Date d acceptation] <> BLANK()
        ))
    ) 
 return  e

 

 

Please advise me a working formula, I m desperate 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @antoinersw 
Missing one CALCULATE. Please try

_€ Projeté et signés =
SUMX (
    VALUES ( 'leads'[Client] ),
    CALCULATE (
        AVERAGEX (
            VALUES ( 'leads'[Numéro] ),
            CALCULATE (
                SUMX (
                    TOPN ( 1, leads, 'leads'[heures_total_presta] ),
                    leads[Duree presta] / 30 * 'leads'[montant_HT_avec_remise]
                ),
                'leads'[Date d acceptation] <> BLANK ()
            )
        )
    )
)

 

View solution in original post

4 REPLIES 4
antoinersw
Regular Visitor

I ve actually changed it a little to fit my usecase and take the top1 for the averageX

 

_€ Projeté et signés =

var e =
SUMX (
    VALUES ( 'leads'[Client] ),
    CALCULATE (
        AVERAGEX (
            // VALUES ( 'leads'[Numéro] )
            TOPN ( 1, leads, 'leads'[heures_total_presta] ),
            CALCULATE (
                SUMX (
                    TOPN ( 1, leads, 'leads'[heures_total_presta] ),
                    leads[Duree presta] / 30 * 'leads'[montant_HT_avec_remise]
                ),
                'leads'[Date d acceptation] <> BLANK ()
            )
        )
    )
)
 return  e
tamerj1
Super User
Super User

Hi @antoinersw 
Missing one CALCULATE. Please try

_€ Projeté et signés =
SUMX (
    VALUES ( 'leads'[Client] ),
    CALCULATE (
        AVERAGEX (
            VALUES ( 'leads'[Numéro] ),
            CALCULATE (
                SUMX (
                    TOPN ( 1, leads, 'leads'[heures_total_presta] ),
                    leads[Duree presta] / 30 * 'leads'[montant_HT_avec_remise]
                ),
                'leads'[Date d acceptation] <> BLANK ()
            )
        )
    )
)

 

Thanks a lot @tamerj1  🙂 

 

Do you happen to know how "hard" that formula is on the scale of the difficulty of DAX ? 

@antoinersw 
Average or perhaps little hard but definitely not easy.

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.