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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
felipevaz
Helper I
Helper I

Using Two Excel Sheet Tables as filter in sum Dax

Hi,

 

I have three Excel tables: (start table, Codes and Subcodes)

 

felipevaz_0-1606789542239.png

 

Using Dax, I want to sum the field Value as a measure when I change the code and subcode (update all)...

 

All table are in the model.

 

I trying to use

 

calculate(sum(table[value],filter(table,table[codes] = codes[codes] && filter(table,table[subcode] = subcodes[subcodes])

 

off course this is giving me an error. I dont know how to implement that. Could you help me please?

 

1 ACCEPTED SOLUTION

@felipevaz , Try meausre like

 

calculate(sum(table[value]),filter(table,table[codes] in values(codes[codes]) && table[subcode] in values(subcodes[subcodes])))

calculate(sum(table[value]),filter(table,table[codes] in allselected(codes[codes]) && table[subcode] in allselected(subcodes[subcodes])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

8 REPLIES 8
wdx223_Daniel
Super User
Super User

Heey, thnx @wdx223_Daniel i didnt know that I could do it...Nice!!

 

In my model I need to allow user to set Code and/or subcode independently...

 

if the subcode is blank then just use the code....

@felipevaz have you try my code? code and subcode are independent. you can update those columns, and click refresh all

@wdx223_Daniel works as well! thank you. I learned a lot with your code. hugs!

amitchandak
Super User
Super User

@felipevaz , Ideally. You can join code and sub code with start table and they should filter automatically.

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

https://unimedpoa-my.sharepoint.com/:x:/g/personal/felipe_vaz_unimedpoa_com_br/EV00g4eywn9Eq6J25nmH3... 

save to your computer the table was loaded into the model

@amitchandak I cant joining the tables cos that is costing a lot of time when refreshing....

 

thats why I tried to load data into data model and use dax to filter the data

 

I forgot to mention that I need to sum the total of value, sum the total of value of selected Code and subcode...

@felipevaz , Try meausre like

 

calculate(sum(table[value]),filter(table,table[codes] in values(codes[codes]) && table[subcode] in values(subcodes[subcodes])))

calculate(sum(table[value]),filter(table,table[codes] in allselected(codes[codes]) && table[subcode] in allselected(subcodes[subcodes])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak worked like a charm! Really thank you for supporting me.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.