Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Diference Between Second and First Order

Hello!

I'm trying to find the difference between the second and first client order.

Through two measures, I was able to find such dates and the difference between them:

2nd order =
VAR temp =
ADDCOLUMNs(
VALUES ( Total[Document Date] ),
"RANK", RANKX (
VALUES ( Total[Document Date] ),
[Document Date], ,
ASC,
DENSE
)
)
RETURN
MINX ( FILTER ( temp, [RANK] = 2 ), [Document Date] )
 
However, when I put this in a table, PowerBi does not calculate such numbers:
 
 

 

How can I turn around this?

It is better to create a new column with the date of the second order? How can I do this?

 

Tks in advance!
Lucas

 

2 Replies

  • littlemojopuppy's avatar
    littlemojopuppy
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

     

    Generally speaking, not a good idea to add columns.  This isn't terrible to do in a measure.  Can you provide some sample raw data to work with?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Do you want to return the value of subtotal? Please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.