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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply

Only get filtered results from connected table

Good morning,

I've been struggling with this for a few days.  I have 2 tables (Budgets & Data), a guage, and a slicer.  I'm trying to get the guage to show the correct target budget no matter Category (or mix of categories) is selected in the slicer.

 

Below is the code I have, but both NoFilter and HasFilter keep returning the same value or those Big Projects with mutiple subprojects get over represented.  I've tried various GROUPBY, SUMMARIZE, etc, and I just cannot get this to work.  What am I doing wrong?  Shouldn't VALUES only return the Categories currently in the filter?

 

 

 

_Target Budget = 
VAR FilterCheck = ISFILTERED('Data'[Category])
VAR NoFilter = SUMX('Budgets', [Budget])
VAR HasFilter = 
    ADDCOLUMNS(
        VALUES('Budgets'[Category]),
        "@Budget", SUMX('Budgets', [Budget])
    )
VAR Result = 
    IF(
        FilterCheck,
        SUMX(HasFilter, [@Budget]),
        NoFilter
    )
RETURN Result

 

 

 

Budgets:

PK_IDCategoryBudget
BP1Big Project 11,000,000
BP2Big Project 22,000,000
BP3Big Project 35,000,000
BP4Big Project 42,000,000

 

Data:

PK_IDFK_IDNameCost
SP1BP1Subproject 1500,000
SP2BP2Subproject 2.11,500,000
SP3BP2Subproject 2.2200,000
SP4BP3Subproject 34,300,000
SP5BP4Subproject 42,500,000

 

Edit 2/1/2024: Edited the pasted formula.  I did a lot of simplifying my code for understanding and screwed up which table a column was tied to.

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @ronnie_roberts 

 

I'm not sure what your measure would have over something like this.

My Budget = SUM( 'Budgets'[Budget] )

 

Take a look at my comparison.

Only get filtered results-from connected table.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

4 REPLIES 4

Thank you for the feedback!  I did a ton of simplifying creating this example and when I set things up as you suggested, yeah SUMX works just fine.  Obviously one of the other things going on in my report is causing the issue.  I'll keep searching.

gmsamborn
Super User
Super User

@ronnie_roberts 

 

Does this help?  I added CALCULATE around your SUMX when defining _HasFilter.

 

_Target Budget 2 = 
VAR _FilterCheck = ISFILTERED('Budgets'[Category])
VAR _NoFilter = SUMX('Budgets', [Budget])
VAR _HasFilter = 
    ADDCOLUMNS(
        VALUES( 'Budgets'[Category] ),
        "@Budget", CALCULATE( SUMX('Budgets', [Budget])  )
    )
VAR _Result = 
    IF(
        _FilterCheck,
        SUMX( 
            _HasFilter, 
            [@Budget]
        ),
        _NoFilter
    )
RETURN 
    _Result

 

 

Can you explain why you wrote your measure that way?  As far as I can tell, [My Budget] mentioned above seems to work.

 

Only get filtered results-from connected table - test.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!
gmsamborn
Super User
Super User

Hi @ronnie_roberts 

 

I'm not sure what your measure would have over something like this.

My Budget = SUM( 'Budgets'[Budget] )

 

Take a look at my comparison.

Only get filtered results-from connected table.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!
gmsamborn
Super User
Super User

Hi @ronnie_roberts 

 

In your measure you refer to 'Data'[Category] but in your tables you say that [Category] is a column of Budget, not Data.

 

Let me know if this helps.



Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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