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
ARob198
Helper IV
Helper IV

Filter sum by another table

I have a problem that seems like it should be easy, but I can't seem to get the formula right. 

 

I have two tables.  One has values by asset by date, the second defines the type of asset.  I need to create a measure or calculated column which sums the value by date and by type to use the values for additional analysis.  The tables are related by Name.  I am not sure how to filter the sum of the values by the Type.

 

Thank you very much.

 

Example:

Table 1  
DateNameValue
1/31/2016AB10
2/29/2016AB11
3/31/2016AB12
1/31/2016AA3
2/29/2016AA4
3/31/2016AA5
1/31/2016AC2.5
2/29/2016AC3.5
3/31/2016AC4.5

 

Table 2 
NameType
ABCash
AAStock
ACCash

 

Desired Result  
DateNameValue
1/31/2016Cash12.5
2/29/2016AB14.5
3/31/2016AB16.5
1 ACCEPTED SOLUTION

hi  @ARob198 

Do you mean that you do a filter in visual level filter and then use the measure result in another Measure?

If so, you need to add the same filter into that visual too, the measure result in based on it row context and filter context.

 

otherwise, you could define it in the measure like this

Measure =CALCULATE( SUM('Table 1'[Value]),'Table 2'[Type]="Cash")

But this will not interaction by slicer.

 

Regards,

Lin

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

View solution in original post

9 REPLIES 9
v-lili6-msft
Community Support
Community Support

hi  @ARob198 

You could try this way as below:

Step1:

Create a relationship between two tables by Name

5.JPG

 

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-create-and-manage-relationships

 

Step2:

Then just create a simple meausre 

Measure = SUM('Table 1'[Value])

 

Step3:

Now drag type into a slicer to filter data as below:

6.JPG

here is sample pbix file, please try it.

 

Regards,

Lin

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

Hello ,  I apologzie but this isn't what I need.  Or maybe I don't understand how it can be used to solve the issue.  Perhaps I am not explaining this correctly.  The tables are already related.  I need to use the filtered value as an input in another calculation- I do not want to see it in a table- so it cannot just be a sum using a filter in a visual.  I need the cash value as an input for other calculations.  What is the formula for a sum that is filtered by a criteria in another table?  Just using Sum(value) does not give me a filtered value to use in another calculation.

 

Thank you

hi  @ARob198 

Do you mean that you do a filter in visual level filter and then use the measure result in another Measure?

If so, you need to add the same filter into that visual too, the measure result in based on it row context and filter context.

 

otherwise, you could define it in the measure like this

Measure =CALCULATE( SUM('Table 1'[Value]),'Table 2'[Type]="Cash")

But this will not interaction by slicer.

 

Regards,

Lin

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

@ARob198 Your desired result is wrong because the solution provided matches that criteria. Please re-evaluate what your desired result is.

toolatejake

 

Can you be more specific?  sum([value]) does not solve my problem without adding a filter and I am having problems creating one inside a measure.  If you are unable to provide more help or an explaination or you are unwilling to provide more detail, please allow someone else to repond.

Anonymous
Not applicable

@ARob198I think we are talking past each other here. What I meant was, the problem as you had laid it out was solved in the solution by @v-lili6-msft . However, you are saying that is incorrect. I was trying to simply propose that you reframe the problem more specifically so members of this forum can help you.

 

As an aside, cross table filters are based on the relationships of the tables, and those relationships are enforced inside measures, unless you modify them the filter with a formula like ALL, SELECTED, and so on. You can find a filter function overview here: https://docs.microsoft.com/en-us/dax/filter-functions-dax

 

 

Hi

As I explained when I replied to

, I cannot have the solution in a table.  I need a measure so that I can use it for other calculations.  Do you know how to solve this as a measure with a filter, without creating another talbe?  Otherwise, please allow me to repost to allow someone else to help me.

Anonymous
Not applicable

Is this a running total? If so, you can use the Quick Measure in PowerBI. https://powerbi.microsoft.com/en-us/blog/quick-measures-preview/

 

If it is not a running total, you should just use a measure with SUM([value]).

 

You probably need a date dimension too though if this is accounting data.

I am not really sure what you mean. I am trying the formula below. I am not getting an error, but the end result is blank. What do you suggest? Thank you for your help.
 
Calculate(SUM('Table1'[VALUE]), filter(ALL(Table2), (Table2[TYPE] = "Cash"&& 'Table1'[NAME DETAIL] = 'Table2'[NAME])))

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.