Forum Discussion
Getting the maximum value for each order
- Anonymous3 years ago
Hi all,
I managed to solve it through af combination of the suggestions posted in the thread.
Thanks to everyone for inputs!
The solution for the time of controls was:
FirstControl = MINX ( TOPN ( 1, 'QualityControl', 'QualityControl'[CheckedDateTime], DESC ), 'QualityControl'[CheckedDateTime] ) SecondControl = MINX ( TOPN ( 2, 'QualityControl', 'QualityControl'[CheckedDateTime], DESC ), 'QualityControl'[CheckedDateTime] )As I actually needed the five latest times of control I just increased the TOPN value for each measure.
Sorry for my late response.
It took some time to get Power BI Desktop updated as I'm not allowed to do it myself.
I've tried to use your suggestion but get the error:
"INDEX Relation paramter may have duplicate rows. That is not allowed."
For the first QC date you could simply use MIN('Quality Control'[Checked datetime]), for the 2nd you can try
Second QC =
VAR Top2 =
TOPN ( 2, 'Quality Control', 'Quality Control'[Checked datetime], ASC )
RETURN
MINX ( Top2, 'Quality Control'[Checked datetime] )
- Anonymous3 years agoNot applicable
I still have issues.
Unfortunately I'm not able to share the data as a DirectQuery connection, but I've made some sample data in Excel. Both Excel and PBIX files are attached.
I've tried to create both of the measures you've suggested.
https://drive.google.com/drive/folders/1vQGG9PGobKcCIm8IxlvhXgwwM7RPyT1z?usp=sharing
Once again, thank you very much for your help.
- johnt753 years ago
Super User
It needs to be MAXX, not MINX
SecondControl = VAR Top2 = TOPN ( 2, 'QualityControl', 'QualityControl'[Checkeddatetime], ASC ) RETURN MAXX ( Top2, 'QualityControl'[Checkeddatetime] )