Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi power BI community
I need a filter that looks at the first three years in a table for each customer_id and include them and exclude the rest.
The relevant colums are the following.
Customer_id: A number that shows the id of each customer
Due_date: The date a invoice has been send.
Total_amount: A number of money that should be added togeter if they are in the first three years of the due_date for each customer.
So far I have this, but it doesn't seem to work.
Solved! Go to Solution.
Hi @ThomasWeppler ,
Thanks to @_AAndrade and @mh2587 for the reply, please allow me to provide another insight:
The dateadd function returns a table containing a column of dates starting from the date in the current context and moving forward or into the past by a specified number of intervals. It must be a date that already exists in the table. If there is no date three years after MinDueDate in your table, it will return a null value.
You can see this example. I have these dates in my table.
To get a date three years from now, it returns empty.
To get the date three days later, the data that already exists in the table is returned.
If you want to get the date three years later, you can use an expression similar to the following.
Measure =
DATE(YEAR(MAX('Table'[date]))+3,MONTH(MAX('Table'[date])),DAY(MAX('Table'[date])))
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ThomasWeppler ,
Thanks to @_AAndrade and @mh2587 for the reply, please allow me to provide another insight:
The dateadd function returns a table containing a column of dates starting from the date in the current context and moving forward or into the past by a specified number of intervals. It must be a date that already exists in the table. If there is no date three years after MinDueDate in your table, it will return a null value.
You can see this example. I have these dates in my table.
To get a date three years from now, it returns empty.
To get the date three days later, the data that already exists in the table is returned.
If you want to get the date three years later, you can use an expression similar to the following.
Measure =
DATE(YEAR(MAX('Table'[date]))+3,MONTH(MAX('Table'[date])),DAY(MAX('Table'[date])))
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
First 3 years = //Try this and just modified the if condition
VAR MinDueDate = CALCULATE(MIN('2905 InvoiceLine'[Duedate]), ALLEXCEPT('2905 InvoiceLine', '2905 InvoiceLine'[customer_id]))
RETURN
IF('2905 InvoiceLine'[Duedate] <= DATEADD(MinDueDate, 3, YEAR) && '2905 InvoiceLine'[Duedate] >= MinDueDate, 1, 0)
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
It has a problem with dateadd. It will not add a variable.
Sure here is some more info.
I have worked a bit more with it and I I have found the first date where an invoice was send. The only thing I need now is to add 3 years to that date.
I have tried with this DAX code to add a new column in my table.
DAX Code = DATEADD('2905 InvoiceLine'[First],3,YEAR)
It works on all the rows where the date is 06/01/2020 and one of the other rows. It seems very weird to me.
Can anyone help me advance from here?
Probably you are getting that date because it's the correct output for all your data.
But if I well understood you need this logic for each invoice right?
If is the case you need to use a measure to do your calculations instead of a calculated column
Proud to be a Super User!
Hi @ThomasWeppler,
Can you provide an example of the current output and the expected output? Or a pbix file with same data so I can look at it?
Proud to be a Super User!
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
115 | |
112 | |
105 | |
95 | |
58 |
User | Count |
---|---|
174 | |
147 | |
136 | |
102 | |
82 |