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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

POWER PIVOT DOES NOT FILTER VIRTUAL TABLE IN EXCEL MODE

Simple thing.

I am creating virtual table in DAX with filtered data which matches some criterias, then I want to display that data by campaigns, but

in Pivot I see only the particular date I have filtered initially, despite the fact that later I do obtain virtual table with all possible campaigns.

In DAX STUDIO I see that table, but when I create measure using that table in EXCEL POWER PIVOT I see only that campaign I was filtering for...

I tried all stuff I had in my mind but now stuck,what can be wrong...

 

TABL= just selects data from initial table and breaks lineage for me later to be joined with the list I need.

test - is the list I need. So it represents list of customers on particular campaign. Then I want to see how they perform in future campaigns and I do naturalleftouterjoin with TABL by their ID and DATASET.

Then filter those which I need. THEN use IN DAX measure and I see the table I need- All campaigns, and all customers placed order in particular campaign.

After I copy all this data in EXCEL POWER PIVOT (green window) create measure and want to see it via PIVOT TABLE I see only that campaign they placed order, all other campaigns are not visible.

 

evaluate                                         

VAR Tabl=selectcolumns(TABLE;

               CUST_ID;TABLE[CUST_ID]+0;

               DATASET;TABLE[DATASET]&"";

               CUST_TYPE;TABLE[CUST_TYPE]+0;

               CAMPAIGN;TABLE[CAMPAIGN]&"";

               SALES;TABLE[SALES]+0;

               ACTIVE;TABLE[ACTIVE]+0;

               LOYALTY_GRADE;TABLE[LOYALTY_GRADE]+0;

               TAXES;TABLE[TAXES]+0

               )                           

VAR times=SELECTCOLUMNS(FILTER(VALUES(TABLE[CAMPAIGN]);[CAMPAIGN]="2020-04");"CAMPAIGN";[CAMPAIGN]&"";"CAMP_ID";"Y")

                                          

VAR test=FILTER(NATURALLEFTOUTERJOIN(Tabl;times);[CAMP_ID]="Y")

                                          

VAR LOYALTY_GRADE_APR2020=FILTER(test;[LOYALTY_GRADE]=1)

                                          

VAR list_apr20_a=SELECTCOLUMNS(LOYALTY_GRADE_APR2020;"DATASET";[DATASET]&"";"CUST_ID";[CUST_ID]+0;"STATUS";"APR_20";"CAMPAIGN";[CAMPAIGN]&"")

                                          

VAR list_apr20=SELECTCOLUMNS(list_apr20_a;"DATASET";[DATASET]&"";"CUST_ID";[CUST_ID]+0;"STATUS";"APR_20")

                                          

                                          

VAR temp1=NATURALLEFTOUTERJOIN(Tabl;list_apr20)

                                          

VAR temp=filter(temp1;[STATUS]<>"")

                                          

VAR result=calculate(sumx(temp;[SALES]))

                                          

                                          

return                               

                                          

calculate(sumx(temp;[SALES])) 

2 REPLIES 2
technolog
Super User
Super User

What is really happening

  1. SELECTCOLUMNS breaks lineage. Once you wrap columns with plus zero or ampersand empty string, they no longer receive filters from the model.
  2. You then join to times that is built from VALUES of Campaign and filtered to April 2020. Inside the Pivot this kills every row except April 2020.
  3. NATURALLEFTOUTERJOIN brings customers back, but because lineage is broken, the Campaign field on Pivot rows does not filter your virtual table. The only reason you see anything at all is that the only surviving branch is the April 2020 one you forced earlier.

Two clean fixes

Fix A minimal change
Make times independent from the current row by using a constant table and push the list of customers back to the base table with TREATAS. This keeps model filters on Campaign working.

Customers in Apr 2020
VAR CustomersApr =
CALCULATETABLE(
SUMMARIZE(
FILTER(
ALL( TABLE ),
TABLE[CAMPAIGN] = "Apr 2020"
&& TABLE[LOYALTY_GRADE] = 1
),
TABLE[DATASET],
TABLE[CUST_ID]
)
)
RETURN CustomersApr

Sales for those customers by any campaign
VAR CustomersApr =
CALCULATETABLE(
SUMMARIZE(
FILTER(
ALL( TABLE ),
TABLE[CAMPAIGN] = "Apr 2020"
&& TABLE[LOYALTY_GRADE] = 1
),
TABLE[DATASET],
TABLE[CUST_ID]
)
)
RETURN
CALCULATE(
SUM( TABLE[SALES] ),
KEEPFILTERS(
TREATAS( CustomersApr, TABLE[DATASET], TABLE[CUST_ID] )
)
)

Put Campaign on rows. The measure will split by the Campaign on the Pivot because the filter now hits the real table through TREATAS. Replace Apr 2020 with your real campaign key.

Fix B keep your pattern but unhook it from the row context
If you really want to keep NATURALLEFTOUTERJOIN then do two things.
Use ALL on Campaign when you build times so it does not depend on VALUES of the current row.
Do not rebuild a copy of the table with SELECTCOLUMNS for columns that need to be filterable. Use the original table in the final SUM or use TREATAS to push your customer list back to the original table.

Example of a constant times table
VAR times =
ROW( "CAMPAIGN", "Apr 2020", "CAMP_ID", "Y" )

Then do your joins, but finish with
RETURN
CALCULATE(
SUM( TABLE[SALES] ),
KEEPFILTERS(
TREATAS( SELECTCOLUMNS( list_apr20, "DATASET", [DATASET], "CUST_ID", [CUST_ID] ),
TABLE[DATASET], TABLE[CUST_ID] )
)
)

Practical debugging steps

  1. Prove the VALUES trap
    Create a quick check measure
    CALCULATE( COUNTROWS( FILTER( VALUES( TABLE[CAMPAIGN] ), TABLE[CAMPAIGN] = "Apr 2020" ) ) )
    On the Campaign Pivot this will be one on Apr 2020 and zero elsewhere. That is exactly the behavior you are propagating into your big measure.
  2. Prove lineage is gone
    Create
    SUMX( SELECTCOLUMNS( TABLE, "C", TABLE[CAMPAIGN] ), 1 )
    It returns the same number for every Campaign row because the Pivot filter does not reach the cloned column.
  3. After switching to TREATAS confirm that Campaign now slices the result. If you need to show campaigns with zero sales turn on Show items with no data in Pivot settings.
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your statement and code, I know that you will need to use SELECTCOLUMN and NATURALLEFTOUTERJOIN function to build virtual tables and then calculate the result as you want. I think your code is complex, please share a sample file with us and show us a screenshot with the result you want. This will make us easier to understand your requirement.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.