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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Vincem35
Helper I
Helper I

Calculate formula and apply a Date filter + select only the first transaction date by client

Dear Community, 

 

I am working with a transaction table such as below:

Client IDTransaction DateSales
11/1/2019 $  100.00
11/1/2018 $  200.00
13/1/2018 $  355.00
14/5/2020 $      5.00
21/1/2019 $  100.00
21/1/2018 $  200.00
23/1/2018 $  355.00
24/5/2020 $      5.00

 

I am seeking your help as i would like to calculate the Sum of Total Sales for the first Transaction Date of each client for a specific period (e.g 2018)
The result using the above table should be: 400$


I have the folllowing formula:

Test =CALCULTATE(
SUM([Sales]), 
[Transaction Date] >="2018-01-01" && [Transaction Date] <="2018-12-31")

But would need to add the filter for the first Transaction by client.

Thanks for your help!

Cheers

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Vincem35 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

Calendar(a calculated table):

Calendar = CALENDARAUTO()

 

There is a relationship between two tables. You may create a measure as below.

Result = 
var tab = 
ADDCOLUMNS(
    SUMMARIZE(
        ALLSELECTED('Table'),
        'Table'[Client ID],
        "MinDate",
        MIN('Table'[Transaction Date])
    ),
    "S",
    CALCULATE(
        SUM('Table'[Sales]),
        FILTER(
            ALL('Table'),
            'Table'[Client ID]=EARLIER('Table'[Client ID])&&
            'Table'[Transaction Date]=EARLIER([MinDate])
        )
    )
)
return
SUMX(
    tab,
    [S]
)

 

Result:

b2.png

b3.png

 

Best Regards

Allan

 

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

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-alq-msft
Community Support
Community Support

Hi, @Vincem35 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

Calendar(a calculated table):

Calendar = CALENDARAUTO()

 

There is a relationship between two tables. You may create a measure as below.

Result = 
var tab = 
ADDCOLUMNS(
    SUMMARIZE(
        ALLSELECTED('Table'),
        'Table'[Client ID],
        "MinDate",
        MIN('Table'[Transaction Date])
    ),
    "S",
    CALCULATE(
        SUM('Table'[Sales]),
        FILTER(
            ALL('Table'),
            'Table'[Client ID]=EARLIER('Table'[Client ID])&&
            'Table'[Transaction Date]=EARLIER([MinDate])
        )
    )
)
return
SUMX(
    tab,
    [S]
)

 

Result:

b2.png

b3.png

 

Best Regards

Allan

 

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

amitchandak
Super User
Super User

@Vincem35 , Check Page 2 in the file attached after signature

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks a lot!
It works well when i set the date as a slicer but i would need to have it in the formula as it is dynamic - Any thoughs?

Thanks again

@Vincem35 , can you explain with an example

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.