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
mpetrilaksb
Frequent Visitor

Filter table only if value in column of other table is not empty

Hello everyone,

 

I need your help. I need to sum amount from journal entries (can't share) if row from journal entry meets criteria from bridge table

mpetrilaksb_0-1637263551792.png

but if value in column is empty in bridge table, i don't want to apply filter to journal entries table column (journal entry table may have value in such column which may be in different case used as criteria). Tables are unrelated.
From resulting filtered table i need to sum one column with amount. I tried calculated column, and I can't to power query by myself that well.
Simply it comes down to based on condition in one table how to not filter other table.

 

Any ideas, please?

Thank you very much in advance,

1 ACCEPTED SOLUTION
mpetrilaksb
Frequent Visitor

Hi @v-rzhou-msft 
not exactly.
if the first table was

CategorySubcategoryValue
Aaa1
Aab2
A 3
Bbb4
Ccc5

 

Values for second table would be:

CategorySubcategoryResult
AA 6
AAaa1
B 4
Bbc0
C 5
Ccc5


But I made it work using wildcard "*" as (,,Levely" is table with conditions, DUZ_ALL is table with values)

VAR
MDCa = IF(ISBLANK(Levely[MD Category]),"*",Levely[MD Category])

VAR MDSCa = IF(ISBLANK(Levely[MD Subcategory]),"*",Levely[MD Subcategory])
VAR ...
RETURN
CALCULATE(SUM(DUZ_ALL[Sum]),
FILTER( DUZ_ALL, CONTAINSSTRING(DUZ_ALL[MD Category], MDCa) && CONTAINSSTRING(DUZ_ALL[MD Subcategory], MDSCa) && ...

Thanks for your willingness!

View solution in original post

2 REPLIES 2
mpetrilaksb
Frequent Visitor

Hi @v-rzhou-msft 
not exactly.
if the first table was

CategorySubcategoryValue
Aaa1
Aab2
A 3
Bbb4
Ccc5

 

Values for second table would be:

CategorySubcategoryResult
AA 6
AAaa1
B 4
Bbc0
C 5
Ccc5


But I made it work using wildcard "*" as (,,Levely" is table with conditions, DUZ_ALL is table with values)

VAR
MDCa = IF(ISBLANK(Levely[MD Category]),"*",Levely[MD Category])

VAR MDSCa = IF(ISBLANK(Levely[MD Subcategory]),"*",Levely[MD Subcategory])
VAR ...
RETURN
CALCULATE(SUM(DUZ_ALL[Sum]),
FILTER( DUZ_ALL, CONTAINSSTRING(DUZ_ALL[MD Category], MDCa) && CONTAINSSTRING(DUZ_ALL[MD Subcategory], MDSCa) && ...

Thanks for your willingness!

v-rzhou-msft
Community Support
Community Support

Hi @mpetrilaksb 

I think you want to calculate sum amount in one table based in another table by filter one column in that table is not blank.

My Sample is as below.

Table:

1.png

Table(2):

2.png

Try this code.

Measure = 
VAR _List = CALCULATETABLE(VALUES('Table (2)'[Category]),FILTER('Table (2)','Table (2)'[Sub]<>BLANK()))
RETURN
SUMX(FILTER('Table','Table'[Category] in _List ),'Table'[Values])

 Result is as below.

1.png

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
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.