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
Kolumam
Post Prodigy
Post Prodigy

Issue with relating direct query and import tables

Hi All,

 

I have two tables one is direct query and other is import model. 

Direct Query Table:

 

Capture.JPG

 

Import Table:

 

Import Table consists of Month, Station ID and Expected Energy

MonthStation IdExpected Energy
   

 

Basically, I need to create relationships in such a way that 

 

IF (Table 1[Eac-MFM] > 0 , Table 2 [Expected Energy], 0) 

 

I tried creating a relationship between the month in both tables and it created many to many relationships but I am not able to execute the above if condition because of direct query limitations.

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

Hi,

 

According to your description, i create two simple tables to test:

DirectQuery table

11.PNG

 

Import table

12.PNG                                                           

Then create a measure:

 

Measure = 
IF (
    COUNTROWS ( 'Sales-2' ) > 0,
    IF (
        SUM ( 'Sales-1'[Sales] ) > 0,
        CALCULATE (
            SUM ( 'Sales-2'[Expected Sales] ),
            'Sales-2'[Category] IN FILTERS ( 'Sales-1'[Category] )
        ),
        0
    )
)

 

Add this measure to DirectQuery table(Sales-1) as a table visual and it shows:

13.PNG

 

Best Regards,

Giotto Zhi

View solution in original post

1 REPLY 1
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create two simple tables to test:

DirectQuery table

11.PNG

 

Import table

12.PNG                                                           

Then create a measure:

 

Measure = 
IF (
    COUNTROWS ( 'Sales-2' ) > 0,
    IF (
        SUM ( 'Sales-1'[Sales] ) > 0,
        CALCULATE (
            SUM ( 'Sales-2'[Expected Sales] ),
            'Sales-2'[Category] IN FILTERS ( 'Sales-1'[Category] )
        ),
        0
    )
)

 

Add this measure to DirectQuery table(Sales-1) as a table visual and it shows:

13.PNG

 

Best Regards,

Giotto Zhi

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.