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
JasonG-BI
Helper I
Helper I

"Countif" across two tables in Direct Query

Hi All,

 

Im really stuck on something that should be so simple.

 

I am trying to Count the Number of Sales Executives that have sales more than Zero. Which is accurate with applied slicers such as Month year and Store. So that we can have a sales revenue divided by Sales Execs.  The sales execs name is in one Table and the Revenue is in another. Im really struggling with the count function of the sales person.

 

The name is in 'Sales Name'[Sales Exec]

 

and the Sales Revenue is in  'Sales Revenue'[Revenue_Awarded]

 

Any help is much appreciated.

 

 Image for community.jpg

 

Im in directy query and the two tables are linked.

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @JasonG-BI

 

Try this MEASURE

 

MEASURE =
CALCULATE (
    COUNT ( 'Sales Name'[Sales Exec] ),
    FILTER (
        ALL ( 'Sales Name'[Sales Exec] ),
        CALCULATE ( SUM ( 'Sales Revenue'[Revenue_Awarded] ) ) > 0
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

Hi @JasonG-BI

 

Try this MEASURE

 

MEASURE =
CALCULATE (
    COUNT ( 'Sales Name'[Sales Exec] ),
    FILTER (
        ALL ( 'Sales Name'[Sales Exec] ),
        CALCULATE ( SUM ( 'Sales Revenue'[Revenue_Awarded] ) ) > 0
    )
)

Regards
Zubair

Please try my custom visuals

Thank you for your reply however this doesnt appear to work in direct query.

 

I get the error message "Function 'Filter' is not supported in this context in DirectQuery mode.

 

Is there another way??Image for community2.jpg

Hi @JasonG-BI

 

Did you add it as a MEASURE or Calculated Column?


Regards
Zubair

Please try my custom visuals

@JasonG-BI

 

here is another way

 

MEASURE =
COUNTROWS (
    FILTER (
        ALL ( 'Sales Name'[Sales Exec] ),
        CALCULATE ( SUM ( 'Sales Revenue'[Revenue_Awarded] ) ) > 0
    )
)

Regards
Zubair

Please try my custom visuals

thank you this is now working with the original solution i just needed to enable a setting in option direct query. This is a massive help. Thanks !!!!

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.