Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sum with filters in different tables - direct query mode

Dear all,

 

I've created a report in PBI Desktop that pulls data in direct query mode from our Dynamics CRM database (on premises, direct SQL query). I want to visualize the opportunity pipeline over the last (and upcoming) months.

I use two tables, the "opportunities" and a "timetable" which contains every day of the last an upcoming years witth the date.

 

I want to visualize the open opportunites and their summarized estimated revenue values at any specific day in the last year. 

The filter is, in plain words: summarize the revenue of any opportunity where the actual close date is "smaller" than the date in the time table or the actual close date contains no value AND the creationdate of the opportunity is before the date in the timetable.

 

I've tested this scenario in "import mode" and it works fine when I create a column in the time table with the following DAX

 

********************************

pipeline = sumx(FILTER(opportunity;
                 AND
                       (OR
                            (IF(opportunity[actualclosedate] > timetable[date];TRUE();FALSE());
                                 ISBLANK(VKC[actualclosedate]));
                       (opportunity[createdon] < timetable[date])));
                opportunity[estimated revenue])

********************************

 

Unfortunatley, it is not allowed to created a column in direct query using SUM function.

The described DAX does not work within a measure.

 

Any suggestions?

 

Thanks.

 

Stefan

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello,

 

just to close the Thread, I switched to Mixed Mode (Preview Features) and added a new Column in an "Import" Dataset.

It works with the above mentioned DAX Formula.

 

Not the exact way I wanted, but ok for the moment.

 

Thanx for the help

View solution in original post

5 REPLIES 5
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

From your formula, it seemed that you have used the data in 'VKC' table, should it be opportunity?

1.PNG

In direct query mode, you could just create a measure and may be you could try to modify your formula as below:

pipeline = sumx(FILTER(opportunity,
                 AND
                       (OR
                            (IF(opportunity[actualclosedate] > MAX(timetable[Date]),TRUE(),FALSE()),
                                 ISBLANK('opportunity'[actualclosedate])),
                       (opportunity[createdon] < MAX(timetable[Date])))),
                opportunity[estimated revenue])

If it still could not work, could you please share some sample data to have a test?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-danhe-msft,

 

first of all, thank you.

Your are right, "VKC" should be "opportunity".

 

The measure formula doesn't work, the shown error is (translated):

"Function "Filter" is not supported in this context in direct query mode"

 

Here you'll find some sample data.

 

opportunity.JPGtimetable.JPG

 

Thanks again.

 

Hi @Anonymous,

Based on my test, it could work on my side to use the "FILTER" function.

 

Could you have checked the "Allow unrestricted measures in DirectQuery mode" by selecting File > Options and settings > Options?

1.PNG

Regards,

Daniel He 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-danhe-msft,

 

thank you for your work.

I'm sorry, but I do not have this option to check.

I'm using the latest update (October) with german localisation.

 

Thank you

Stefan

Anonymous
Not applicable

Hello,

 

just to close the Thread, I switched to Mixed Mode (Preview Features) and added a new Column in an "Import" Dataset.

It works with the above mentioned DAX Formula.

 

Not the exact way I wanted, but ok for the moment.

 

Thanx for the help

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.