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

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, @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:

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, @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:

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.

Anonymous
Not applicable

@Jihwan_Kim  could you help

amitchandak
Super User
Super User

@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
Not applicable

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

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.