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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bvanderwatt
Helper III
Helper III

First order / date

Good Day 

 

I am trying to add a calculated column or measure to identify the first time an order was placed for a specific product. 

 

I have a date table connected to my product table. 

 

But I'm not sure how to identify the first date based on my data set. 

 

Any help will be much appreciated 🙂 

1 ACCEPTED SOLUTION

Hi @bvanderwatt 

 

If I'm understanding what you're after, you should be able to use:

 

Total Between Dates = CALCULATE ( SUM ( 'Table'[Amount] ) , FILTER ( 'Table' , 'Table'[Date] >= 'Table'[FirstTransactionDate] && 'Table'[Date] <= 'Table'[FirstTransactionDate +6M] ) )

 

Hope this helps 🙂

 

If the post has been solved, make sure to close it off by marking the comments as solution(s) so that others can also use it! 🙂

 

Cheers again!

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

View solution in original post

6 REPLIES 6
TheoC
Super User
Super User

Hi @bvanderwatt 

 

Without knowing your data model / structure, I cannot provide an exact solution. However, if you go to this link (https://community.powerbi.com/t5/Desktop/Calculating-date-time-differences/m-p/2505774), I have provided a solution to something very similar.  Just go straight to step 2 which is "Calculated column to return the Min DateTime by Station ID".

 

_MinDatebyProduct = 

VAR _Product = 'Table'[Product]
VAR _MinDate = MINX ( FILTER ( ALL ( 'Table' ) , 'Table'[Product] = _Product ) , 'Table'[Date] )

RETURN

_MinDate

 

The above should be generic and you can just change the name of your Table and Column to complete your solution 🙂

 

Hope this helps!

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Hi. Thank you very mcuh for your reply. I've added the below calculated columns for the first transaction date and 6 months from the first transaction date. 

 

However, I'm not sure how to calculate the sales between these two dates. Any chance you can assist? 

 

bvanderwatt_0-1655246056300.png

 

bvanderwatt_1-1655246079348.png

 

Hi @bvanderwatt 

 

If I'm understanding what you're after, you should be able to use:

 

Total Between Dates = CALCULATE ( SUM ( 'Table'[Amount] ) , FILTER ( 'Table' , 'Table'[Date] >= 'Table'[FirstTransactionDate] && 'Table'[Date] <= 'Table'[FirstTransactionDate +6M] ) )

 

Hope this helps 🙂

 

If the post has been solved, make sure to close it off by marking the comments as solution(s) so that others can also use it! 🙂

 

Cheers again!

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Thank you so much for helping me, I really appreciate it. 

 

Last question, hopefully 🙂 

 

I need to add a filter to my "first transaction" calc, because it's also taking into account my budget values. How could I restrict it to only look at the column called "inv+order?"

 

FirstTransactionDate =
CALCULATE (
FIRSTDATE ( 'Combined Sales'[InvoiceDate] ),
FILTER ( 'Combined Sales', 'Combined Sales'[StockCode] = EARLIER ( 'Combined Sales'[StockCode] ) ))

bvanderwatt_0-1655247708077.png

 

Hi @bvanderwatt 

 

You need to integrate ALLEXCEPT which filters out everything else.  

 

As much as I want to continue to help on this post, we have moved far away from what the original post was about and if others are searching for similar assistance, they won't be able to identify the solution on here. 

 

I'm more than happy if you want to add a new post or send a private message, and I can assist further that way. But we need to close this post off because it's well beyond the initial issue. 

 

I hope you understand and please don't think I'm being rude... I'm just conscious of others who will look to use this post for their assistance. 

 

Look forward to helping further through one of the other two means presented. Please ensure to close this post off by marking the relevant comment(s) as a solution.

 

Cheers,

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

No problem. I've accepted the solution and created a new post. I've also tagged you in it 🙂 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.