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
Anonymous
Not applicable

Calculated Field to evaluate if transaction was the first made by user

Hi

I have a table which contains transaction-ID, transaction-date and user-id.

I need to be add an additional field which evaluates if a respective transaction was the first made by the user or not.

 

Screenshot below. Column H (yellow marked) is essentially the desired result. In this example user 1428 first transaction was made on September 7 2017, and is therefore to be marked as "first transaction". All following transactions made by this user are "Further transactions".

 

Screenshot 2023-10-19 at 11.55.13.png

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

You can try creating a calculated column. Basiclly it's to find out the earliest date group by user id.

Column = VAR _MINDATE= CALCULATE(MIN('Table'[DATE]),FILTER('Table',[UserID]=EARLIER('Table'[UserID])))
RETURN IF([DATE]=_MINDATE,"First transactions","Further transactions")

vstephenmsft_0-1698053372582.png

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

You can try creating a calculated column. Basiclly it's to find out the earliest date group by user id.

Column = VAR _MINDATE= CALCULATE(MIN('Table'[DATE]),FILTER('Table',[UserID]=EARLIER('Table'[UserID])))
RETURN IF([DATE]=_MINDATE,"First transactions","Further transactions")

vstephenmsft_0-1698053372582.png

 

 

Best Regards,

Stephen Tao

 

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

devesh_gupta
Impactful Individual
Impactful Individual

@Anonymous 

  • In Power Query Editor, select the table containing transaction data.

  • Go to the "Home" tab and click on "Advanced Editor".

  • Replace the existing code with the following M code:

 

let
    Source = YourTableNameHere, // Replace with your actual table name
    GroupedTable = Table.Group(Source, {"user-id"}, {{"MinDate", each List.Min([transaction-date]), type datetime}}),
    MergedTable = Table.Join(Source, "user-id", GroupedTable, "user-id"),
    AddFirstTransactionColumn = Table.AddColumn(MergedTable, "First Transaction", each if [transaction-date] = [MinDate] then "First Transaction" else "Further Transactions")
in
    AddFirstTransactionColumn

 

  • Make sure to replace YourTableNameHere with the actual name of your table.
  • Click "OK" to apply the changes.

Now, you should have an additional column named "First Transaction" that indicates whether a transaction is the first made by the user or not.

If you find this insightful, please provide a Kudo and accept this as a solution.

@Anonymous As you kudoed this reply, if it works for you then can you mark it as a solution so that other users can find it more easily. Thanks.

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.