Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I already got the solution for the next table with Power Query (grouping, indexing, combining, expanding, etc.), but when I load all the data, Power BI can't process it, it takes hours without getting the final report.
I have the "Sequence" (it is already grouped) and "Value" columns and at the end I added three indexes and combined the table also three times against itself (more than half millon rows aprox), to get the next three values; I think these three final combining and expanding processes are the reason for this delay. Somebody can supply a DAX code to avoid long process time.
By the way, the previous combining and expanding commands are also slow, but at least take no more than 5 minutes to process.
Source | Resuts | |||
Sequence | Value | Next1 | Next2 | Next3 |
1 | SKU | MTTO | CIP | CAM |
2 | MTTO | CIP | CAM | SKU |
4 | CIP | CAM | SKU | CAM |
5 | CAM | SKU | CAM | MTTO |
6 | SKU | CAM | MTTO | |
10 | CAM | MTTO | ||
11 | MTTO |
Solved! Go to Solution.
Hi @Anonymous ,
If you want a measure in table visual, parry2k’s solution is proper and great.
But if you want actual column in table, We can create following calculate columns to meet your requirement.
Next 1 =
var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence])))
return
CALCULATE(MAX('Table'[Value]),FILTER('Table','Table'[Sequence]=x))
Next 2 =
var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence])))
return
CALCULATE(MAX('Table'[Next 1]),FILTER('Table','Table'[Sequence]=x))
Next 3 =
var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence])))
return
CALCULATE(MAX('Table'[Next 2]),FILTER('Table','Table'[Sequence]=x))
And the result like this,
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
If you want a measure in table visual, parry2k’s solution is proper and great.
But if you want actual column in table, We can create following calculate columns to meet your requirement.
Next 1 =
var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence])))
return
CALCULATE(MAX('Table'[Value]),FILTER('Table','Table'[Sequence]=x))
Next 2 =
var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence])))
return
CALCULATE(MAX('Table'[Next 1]),FILTER('Table','Table'[Sequence]=x))
Next 3 =
var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence])))
return
CALCULATE(MAX('Table'[Next 2]),FILTER('Table','Table'[Sequence]=x))
And the result like this,
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Greg,
That's right. Columns "Sequence" and "Value" are the source data, and results are what I need.
Comment: The numbers in the "Sequence" column are illustrative, because they are the result of previous grouping commands. I use that column only to preserve date/time stamp, removed from this last table. I removed all unnecessary columns to avoid excessive processing time.
@Anonymous here you go, you can surely merge these measure to not create sequence measures
Next 1 Sequence =
VAR __currentRow = SELECTEDVALUE ( Next[Sequence] )
RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next) , Next[Sequence] > __currentRow )
Next 2 Sequence =
VAR __currentRow = [Next 1 Sequence]
RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next) , Next[Sequence] > __currentRow )
Next 3 Sequence =
VAR __currentRow = [Next 2 Sequence]
RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next ) , Next[Sequence] > __currentRow )
Next 1 =
VAR __sequence = [Next 1 Sequence]
RETURN CALCULATE ( SELECTEDVALUE ( Next[Value] ), ALL(), Next[Sequence] = __sequence )
Next 2 Sequence =
VAR __currentRow = [Next 1 Sequence]
RETURN
CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next) , Next[Sequence] > __currentRow )
* DIVIDE ( __currentRow, __currentRow )
Next 3 Sequence =
VAR __currentRow = [Next 2 Sequence]
RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next ) , Next[Sequence] > __currentRow )
*
DIVIDE ( __currentRow, __currentRow )
Value Max = SELECTEDVALUE( Next[Value] )
and here is the output
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k !
I'm missing how did you calculate "Next 2" and "Next 3" measures, since you send "Next 2 Sequence" and "Next 3 Sequence" twice.
@Anonymous not sure if I understood your question, drop all sequence measures in the table visual and you will get the answer.
Would appreciate Kudos 🙂 if my solution helped.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you very much @parry2k !
Sorry, but I'm not (still) such an expert to use table visual and I didn't require the solution as an added column.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
79 | |
58 | |
36 | |
33 |
User | Count |
---|---|
93 | |
59 | |
59 | |
49 | |
41 |