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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 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.

Top Solution Authors