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
texmexdragon2
Helper V
Helper V

userelationship question and dax patterns

Hi Community  - 

 

I am using the pattern below from the great SQLBI team.   However, I think their pattern assumes a date table with direct relationship to Order Date on the sales table.   I have a date table, but the primary relationship is to a different date (Due Date).     

 

I do have an indirect relationship established with the Order Date and I can't change my relationships so I need to invoke the USERELATIONSHIP function.   I've tried placing that function in several places, and nothing seems to work. 

 

Any guidance is appreciated.     

 

New and returning customers – DAX Patterns

 

Date New Customer =
CALCULATE(CALCULATE (                                       
    MIN (SalesOrdersALL[Order Date]),                                                            
    ALLEXCEPT (                
        SalesOrdersALL,                            
        SalesOrdersALL[CustNum],  
        Dim_Customers
    )))
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @texmexdragon2 ;

Try it.

Date New Customer =
    CALCULATE (
        MIN ( SalesOrdersALL[Order Date] ),
        ALLEXCEPT ( SalesOrdersALL, SalesOrdersALL[CustNum] ),
        USERELATIONSHIP ( SalesOrdersALL[CustNum], Dim_Customers[CustNum] )
    )

Or 

Date New Customer =
CALCULATE (
    MIN ( SalesOrdersALL[Order Date] ),
    FILTER (
        ALL ( SalesOrdersALL ),
        SalesOrdersALL[CustNum] = MAX ( Dim_Customers[CustNum] )
    )
)


Best Regards,
Community Support Team _ Yalan Wu
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

1 REPLY 1
v-yalanwu-msft
Community Support
Community Support

Hi, @texmexdragon2 ;

Try it.

Date New Customer =
    CALCULATE (
        MIN ( SalesOrdersALL[Order Date] ),
        ALLEXCEPT ( SalesOrdersALL, SalesOrdersALL[CustNum] ),
        USERELATIONSHIP ( SalesOrdersALL[CustNum], Dim_Customers[CustNum] )
    )

Or 

Date New Customer =
CALCULATE (
    MIN ( SalesOrdersALL[Order Date] ),
    FILTER (
        ALL ( SalesOrdersALL ),
        SalesOrdersALL[CustNum] = MAX ( Dim_Customers[CustNum] )
    )
)


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

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.