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.
Hi,
I'm trying to create a new column (I'll name it "next_date") in which I'd like to have the next date associated to the same product.
For example:
-In line 5 there would be 1 - 8/02/2016 - 10/02/2016
-In line 3 and 8 there would be 3 - 8/02/2016 - 8/02/2016 because for each one of the two lines there's another line with the same date.
-If there's no next_date like for line 7 the cell have to remain blank.
I started typing a dax formula with CALCULATE function but I can't find a way to properly filter on the same column (date) having a condition of equality based on another column (product ID).
You can first add an index column in Query Editor as below.
Then close and apply Query Editor, create a calculate Column with following formula.
Column = CALCULATE ( MAX ( Table1[date] ), FILTER ( ALL ( Table1 ), EARLIER ( Table1[product ID] ) = Table1[product ID] && EARLIER ( Table1[date] ) <= Table1[date] && EARLIER ( Table1[Index] ) <> Table1[Index] ) )
Best Regards,
Herbert
Thank you, I think your solution is logically perfect, but the problem is that I tested it on a 400K rows table and it crashes after reaching 13GB RAM, the target is to have it working on a 2 million rows table.
Maybe we can rewrite it as an M (Power Query code) and execute it before the dataset creation?
How about using following updated DAX formula?
Next_Date = CALCULATE ( MIN ( Table1[Date] ), FILTER ( ALLEXCEPT ( Table1, Table1[product ID] ), EARLIER ( Table1[date] ) <= Table1[date] && EARLIER ( Table1[Index] ) <> Table1[Index] ) )
Best Regards,
Herbert
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |