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
Suyheng
Frequent Visitor

Lookup values in Dax (No Relationship in two tables)

Dear All,

Could you help on solving the dax code for the calulation below:

I want to caluclate the sum of revenue collect for year 2018 for the sale in year <2017 where my sale year is in HS table.

 

CALCULATE(SUM(NHSRev[TPaid]),NHSRev[R Year]>2018,
HS[SPA Date (Year)]<"2017",
    NHSRev[SID Ref]<>BLANK(),
        NHSRev[Sale Type]="Payoff",
CROSSFILTER(HS[SPA Date],'Calendar'[Date],Both)
)

Power Pivot Diagram View.PNG

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

Hi Suyheng,

 

Based on your description, you want to enable the indicated relationship between two tables in DirectQuery/Live Connection mode, right?

 

Suppose NHSRev[SID Ref] and HS[SID Ref]) have default relationship between each other, to achieve your requirement, you can use USERELATIONSHIP() instead of LOOKUPVALUE() like below:

 

CALCULATE(SUM(NHSRev[TPaid]),NHSRev[R Year]>2018,
HS[SPA Date (Year)]<"2017",
    NHSRev[SID Ref]<>BLANK(),
        NHSRev[Sale Type]="Payoff",
CROSSFILTER(HS[SPA Date],'Calendar'[Date],Both),

USERELATIONSHIP(NHSRev[SID Ref], HS[SID Ref])
)

 

Best Regards,

Jimmy Tao

View solution in original post

1 REPLY 1
v-yuta-msft
Community Support
Community Support

Hi Suyheng,

 

Based on your description, you want to enable the indicated relationship between two tables in DirectQuery/Live Connection mode, right?

 

Suppose NHSRev[SID Ref] and HS[SID Ref]) have default relationship between each other, to achieve your requirement, you can use USERELATIONSHIP() instead of LOOKUPVALUE() like below:

 

CALCULATE(SUM(NHSRev[TPaid]),NHSRev[R Year]>2018,
HS[SPA Date (Year)]<"2017",
    NHSRev[SID Ref]<>BLANK(),
        NHSRev[Sale Type]="Payoff",
CROSSFILTER(HS[SPA Date],'Calendar'[Date],Both),

USERELATIONSHIP(NHSRev[SID Ref], HS[SID Ref])
)

 

Best Regards,

Jimmy Tao

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.