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 @RicoZhou 
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 @RicoZhou 
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!

RicoZhou
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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Top Solution Authors