cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Azat_Aliaskarov
Helper I
Helper I

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 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Azat_Aliaskarov 

 

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:

v-angzheng-msft_0-1619689983314.png

v-angzheng-msft_1-1619689983315.png

Result:

v-angzheng-msft_2-1619689983317.jpeg

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.

View solution in original post

4 REPLIES 4
v-angzheng-msft
Community Support
Community Support

Hi, @Azat_Aliaskarov 

 

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:

v-angzheng-msft_0-1619689983314.png

v-angzheng-msft_1-1619689983315.png

Result:

v-angzheng-msft_2-1619689983317.jpeg

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.

View solution in original post

Azat_Aliaskarov
Helper I
Helper I

@Jihwan_Kim  could you help

amitchandak
Super User IV
Super User IV

@Azat_Aliaskarov , 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 )

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

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

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors