Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

get result by first date

Hi all,
I'm trying to solve following issue, but can't make it.
I need to get name (table 2) but filtered by first date (not last) (table 1).
'Table1' linked to 'Table 2' through 'user_id'

This is simplified table, I applied following to get this:

cscart_order_logs[action]="rus_order_logs_order_changed",
cscart_order_logs[user_id]<>0,
cscart_order_logs[description_c.2]=BLANK())

In this case, with applied filters first date is 02.03.2021 10:41, so the user_id have to be 44698


table 1

order_iduser_idactionDatedescription_c.2
9739644698rus_order_logs_order_changed02.03.2021 10:41 
9739644698rus_order_logs_order_changed06.03.2021 11:04 
9739650679rus_order_logs_order_changed17.03.2021 18:35 

 

table 2

user_idName
44698Patrick
50679Anna
11122Angela
......

 

@Ashish_Mathur 

@Greg_Deckler 

@Jihwan_Kim 
@marcorusso 

@AlB 

  • Hi, Anonymous 

     

    I'm not quite sure what you expect the output to be, If you could provide the output you expect, the problem will be better resolved.

    there I assume that it is grouped by order-ID and user-ID to return the user name of the earliest date

    Try to create a measure below:

    Return name =
    VAR _minDate =
        MINX (
            FILTER (
                'Table',
                'Table'[order_id] = 'Table'[order_id]
                    && 'Table'[user_id] = 'Table'[user_id]
            ),
            'Table'[Date]
        )
    RETURN
        CALCULATE (
            SELECTEDVALUE ( Table2[Name] ),
            FILTER (
                'Table',
                'Table'[order_id] = 'Table'[order_id]
                    && 'Table'[user_id] = 'Table'[user_id]
                    && 'Table'[Date] = _minDate
            )
        )
    

    I created a simple sample to illustrate this.

    Sample:

    Result:

    Is this close to what you want?

     

    Please refer to the attachment below for details

     

     

    Is this the result you want? Hope this is useful to you

    Please feel free to let me know If you have further questions

     

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

4 Replies

  • Anonymous , Try measures like these for all column other the user_id and date

     

    order_id =
    VAR __id = MAX ('Table'[user_id] )
    VAR __date = CALCULATE ( MAX('Table'[date] ), ALLSELECTED ('Table' ), 'Table'[user_id] = __id )
    CALCULATE ( max ('Table'[order_id] ), VALUES ('Table'[user_id] ),'Table'[user_id] = __id,'Table'[date] = __date )

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Sorry, I did not mention one thing, I made little correction, could you please check?

  • Hi, Anonymous 

     

    I'm not quite sure what you expect the output to be, If you could provide the output you expect, the problem will be better resolved.

    there I assume that it is grouped by order-ID and user-ID to return the user name of the earliest date

    Try to create a measure below:

    Return name =
    VAR _minDate =
        MINX (
            FILTER (
                'Table',
                'Table'[order_id] = 'Table'[order_id]
                    && 'Table'[user_id] = 'Table'[user_id]
            ),
            'Table'[Date]
        )
    RETURN
        CALCULATE (
            SELECTEDVALUE ( Table2[Name] ),
            FILTER (
                'Table',
                'Table'[order_id] = 'Table'[order_id]
                    && 'Table'[user_id] = 'Table'[user_id]
                    && 'Table'[Date] = _minDate
            )
        )
    

    I created a simple sample to illustrate this.

    Sample:

    Result:

    Is this close to what you want?

     

    Please refer to the attachment below for details

     

     

    Is this the result you want? Hope this is useful to you

    Please feel free to let me know If you have further questions

     

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