cancel
Showing results for 
Search instead for 
Did you mean: 
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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors