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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Sibrulotte
Helper IV
Helper IV

Sum of transactions for a client after an event from another table

Hi, 

I tried hard to work with Copilot to come up with the proper measure, but I'm turning to real people for help now.

 

I have a transactions table:

EpargnantSource_Code DateReport_Date Montant

C00120 septembre 2024300
C00110 octobre 2024200
C00215 octobre 2024150
C00325 décembre 2024400
C00110 novembre 2024250
C00315 janvier 2025350

 

And a telemarketing table listing calls made to those clients:

 

EpargnantSource_codecreatedon

C00115 septembre 2024
C0021 octobre 2024
C0015 novembre 2024
C00320 décembre 2024

 

And lastly a numeric range with a single value in a slicer from 1 to 60 (representing days after the phone call) called NB_jours_télémarketing.

 

I'm looking to calculate transaction amounts after a phone call was made, within a certain amount of days determined by the numeric value in NB_jours_télémarketing.

 

Copilot insists this should work:

 
SommeTransactionsApresAppel =
VAR NbJours = SELECTEDVALUE('NB_jours_télémarketing'[NB_jours_télémarketing Value])
RETURN
SUMX (
    'Télémarketing',
    VAR DateAppel = 'Télémarketing'[createdon]
    VAR CodeClient = 'Télémarketing'[EpargnantSource_code]
    RETURN
        CALCULATE (
            SUM ( TransactionEpargnant[Montant] ),
            FILTER (
                ALL ( TransactionEpargnant ),
                TransactionEpargnant[EpargnantSource_Code] = CodeClient
                    && TransactionEpargnant[DateReport_Date] > DateAppel
                    && TransactionEpargnant[DateReport_Date] <= DateAppel + NbJours
            )
        )
)
 
 
But I have token errors, and and the SELECTEDVALUE('NB_jours_télémarketing'[NB_jours_télémarketing Value]) turns out underlined in red.
 
Does anyone have a helping brain?
1 ACCEPTED SOLUTION
mh2587
Super User
Super User

SommeTransactionsApresAppel := //Try this
VAR NbJours =
    SELECTEDVALUE('NB_jours_télémarketing'[NB_jours_télémarketing Value], 30) 
RETURN
    SUMX (
        'Télémarketing',
        VAR DateAppel = 'Télémarketing'[createdon]
        VAR CodeClient = 'Télémarketing'[EpargnantSource_code]
        RETURN
            CALCULATE (
                SUM ( TransactionEpargnant[Montant] ),
                FILTER (
                    TransactionEpargnant,
                    TransactionEpargnant[EpargnantSource_Code] = CodeClient &&
                    TransactionEpargnant[DateReport_Date] > DateAppel &&
                    TransactionEpargnant[DateReport_Date] <= DateAppel + NbJours
                )
            )
    )

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



View solution in original post

2 REPLIES 2
Sibrulotte
Helper IV
Helper IV

Works great. What did the ,30 add to the selectedvalue ?

It'S basically the default value?

mh2587
Super User
Super User

SommeTransactionsApresAppel := //Try this
VAR NbJours =
    SELECTEDVALUE('NB_jours_télémarketing'[NB_jours_télémarketing Value], 30) 
RETURN
    SUMX (
        'Télémarketing',
        VAR DateAppel = 'Télémarketing'[createdon]
        VAR CodeClient = 'Télémarketing'[EpargnantSource_code]
        RETURN
            CALCULATE (
                SUM ( TransactionEpargnant[Montant] ),
                FILTER (
                    TransactionEpargnant,
                    TransactionEpargnant[EpargnantSource_Code] = CodeClient &&
                    TransactionEpargnant[DateReport_Date] > DateAppel &&
                    TransactionEpargnant[DateReport_Date] <= DateAppel + NbJours
                )
            )
    )

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors