Initial value for Enum field returning the next value from the list

Good afternoon!

I need to return the next value in a sequence, that is, in a training application I need to return the next training session performed by a given user as the initial value. For example, there is a list of training sessions, WORKOUT A, WORKOUT B, WORKOUT C, and the previous training session was WORKOUT C. In this case, I need the initial value returned in the next training session entry to be WORKOUT A.

I am using this method based on a suggestion from this community:

ANY(
SELECT(
treinoPrevisto[treino],[idPrev] = MAXROW("treinoPrevisto", "_RowNumber")
)
)

However, it only returns the last training session performed and not the one following it.

NOTE: the view already has a VALID IF with the user filter:
FILTER("treino",AND([user]=[_THISROW].[user],[status]="Aberto"))

How can I complement the formula so that TREINO A is returned?

 

Solved Solved
0 4 166
2 ACCEPTED SOLUTIONS

Treino Initial Value statement

SWITCH(
ANY(
SELECT(
treinoPrevisto[treino],[idPrev] = MAXROW("treinoPrevisto", "_RowNumber")
)
),
"Treino A", "Treino B",
"Treino B", "Treino C",
"Treino C", "Treino D",
"Treino D", "Treino A",
""
)

IF the list of workouts is added to then this statement will have to maintained as well. 

View solution in original post

Extending @Trevwiller 's solution, if you have more than one training sequence patterns, you create TRAINING PATTERN, TRAINING PATTERN DETAILS (parent child) tables where the DETAILS table would have fields like

ID, TRAINING_PATTERN_Ref, PREVIOUS_TRAINING, NEXT_TRAINING.

USERS table should recognize which pattern each user is training under.

View solution in original post

4 REPLIES 4

I am not clear what tables you have.  In your example,  what does the table "treinoPrevisto" represent?  Completed trainings?  Can we see the table definition?  

It would seem you need 2 tables:

1)  all possible trainings and the sequence they should be completed.  I would use a "Training Order" column
2)  Completed trainings which I presume would have rows by user.

The idea would be to find the latest/maximumally completed training and lookup that training row to identify the next training.  

i could tell you how I would do this but that may not fit with what you have built so far.  

 

"The idea would be to find the latest/maximumally completed training and lookup that training row to identify the next training. "  

That's exactly the idea.

I can already find the last workout, but something is missing so that the next one in the sequence can return.

I have all the speadsheets you menitoned, I'll include images to make it easier.Captura de tela 2025-01-15 133441.png         Captura de tela 2025-01-15 133504.png

 

 

 

 

 

 

 

 

 

What I need to do is speed up this process, that is, choose the user (in the user app this is also automatic) and for each user it must return the next workout that he will do in the Initial Value.

Thank you for you interest

Treino Initial Value statement

SWITCH(
ANY(
SELECT(
treinoPrevisto[treino],[idPrev] = MAXROW("treinoPrevisto", "_RowNumber")
)
),
"Treino A", "Treino B",
"Treino B", "Treino C",
"Treino C", "Treino D",
"Treino D", "Treino A",
""
)

IF the list of workouts is added to then this statement will have to maintained as well. 

Extending @Trevwiller 's solution, if you have more than one training sequence patterns, you create TRAINING PATTERN, TRAINING PATTERN DETAILS (parent child) tables where the DETAILS table would have fields like

ID, TRAINING_PATTERN_Ref, PREVIOUS_TRAINING, NEXT_TRAINING.

USERS table should recognize which pattern each user is training under.

Top Labels in this Space