Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

By the same ID I have 2 or more order numbers, but I need just the lowest

Hi everyone,

 

Maybe some one could help me in this question.

 

In dax I have some table:

 

ID                  ORDER            RESULT

121212                1                      1

121212                2                      1

121212                3                      1

 

If I have by the same ID ORDER 1 and ORDER 2 please give me just ONE RESULT, THEN 1.

If I have diferents ID let it so.

 

Thank you.

 

 

 

1 ACCEPTED SOLUTION

@Anonymous 

 

You may use DAX below to add a calculated column.

Column =
MINX (
    FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
    'Table'[ORDER]
)

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
JarroVGIT
Resident Rockstar
Resident Rockstar

Alright, just as a bit of feedback: the WHOLE CAPS THING kinda makes it seem like you are screaming 😉 It is not necessary, there are a lot of people willing to help you out if you formulate your question to the point and complete.

 

To your question: what are you expecting as a result? Do you want a filter? Are you expecting one value (the value of column RESULT)? 

If you want to get a filter context where you only get the row with the lowest ORDER, then try this:

VAR curID = Table[ID]
VAR minOrder = CALCULATE(MIN(Table[ORDER]), FILTER(ALL(Table), Table[ID] = curID))
RETURN
FILTER(Table, Table[ID] = curID && Table[ORDER] = minOrder)

These are parts of valid DAX but without knowing what your expected result is, we can't provide you with a solid answer. 

Your logic is clear, you expected output isn't.

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you for your answer djerro123,

 

what I expect to do is to get just one order number.

 

ID                           ORDER NR                     (ORDER NR2)

 

121212                           1                                      1

121212                           2                                      1

121212                           3                                      1

121200                           1                                      1

121201                           2                                      2

121212                           4                                      1

131313                           3                                      3

131313                           4                                      3

141414                           2                                      2

141414                           3                                      2

 

What I supose to get is just the result form (ORDER NR2).

 

Thank you.

@Anonymous 

 

You may use DAX below to add a calculated column.

Column =
MINX (
    FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
    'Table'[ORDER]
)

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-chuncz-msft  Hi and thank you for your answer, it works great if we have at all in the same table as a column. But how could it works when we have it in separate table1 whithout a merge at ETL?

Anonymous
Not applicable

Thank you for your answer djerro123,

 

what I expect to do is to get just one order number.

 

ID                           ORDER NR                     (ORDER NR2)

 

121212                           1                                      1

121212                           2                                      1

121212                           3                                      1

121200                           1                                      1

121201                           2                                      2

121212                           4                                      1

131313                           3                                      3

131313                           4                                      3

141414                           2                                      2

141414                           3                                      2

 

What I supose to get is just the result form (ORDER NR2).

 

Thank you.

Anonymous
Not applicable

@JarroVGIT 

 

What I expect to do is to get just one order number, the lowest filtered.

 

ID                           ORDER NR                     (ORDER NR by the Lowest Value)

 

121212                           1                                      1

121212                           2                                      1

121212                           3                                      1

121200                           1                                      1

121201                           2                                      2

121212                           4                                      1

131313                           3                                      3

131313                           4                                      3

141414                           2                                      2

141414                           3                                      2

 

Table result:

 

121212                                                                    1

121200                                                                    1

121201                                                                    2

131313                                                                    3

141414                                                                    2                  

 

Thank you.

Anonymous
Not applicable

Thank you for your answer djerro123,

 

what I expect to do is to get just one order number.

 

ID                           ORDER NR                     (ORDER NR2)

 

121212                           1                                      1

121212                           2                                      1

121212                           3                                      1

121200                           1                                      1

121201                           2                                      2

121212                           4                                      1

131313                           3                                      3

131313                           4                                      3

141414                           2                                      2

141414                           3                                      2

 

What I supose to get is just the result form (ORDER NR2).

 

Thank you.

Anonymous
Not applicable

Thank you for your answer djerro123,

 

what I expect to do is to get just one order number.

 

ID                           ORDER NR                     (ORDER NR2)

 

121212                           1                                      1

121212                           2                                      1

121212                           3                                      1

121200                           1                                      1

121201                           2                                      2

121212                           4                                      1

131313                           3                                      3

131313                           4                                      3

141414                           2                                      2

141414                           3                                      2

 

What I supose to get is just the result form (ORDER NR2).

 

Thank you.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.