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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors