Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Solved! Go to Solution.
Yeah, I think you can refactor it to combine FilterA and IgnoreA like this:
Test =
VAR A = CALCULATE ( [...] )
VAR B = CALCULATE ( [...] )
VAR C = CALCULATE ( [...] )
VAR D = CALCULATE ( [...] )
VAR FilterA = FILTER ( fact, IF ( ISEMPTY ( A ), NOT fact[A] IN A, fact[A] IN A ) )
VAR FilterB = FILTER ( fact, IF ( ISEMPTY ( B ), NOT fact[B] IN B, fact[B] IN B ) )
VAR FilterC = FILTER ( fact, IF ( ISEMPTY ( C ), NOT fact[C] IN C, fact[C] IN C ) )
VAR FilterD = FILTER ( fact, IF ( ISEMPTY ( D ), NOT fact[D] IN D, fact[D] IN D ) )
RETURN
CALCULATE ( [Delta-P], FilterA, FilterB, FilterC, FilterD )
Hello there @Anonymous ! Does this work for you?
Test =
VAR PersonaPortfolio =
CALCULATETABLE (
VALUES ( 'Persona Choices (Portfolio)'[Portfolio] ),
'Persona Choices (Portfolio)'[User] = USERPRINCIPALNAME ()
)
RETURN
SWITCH (
TRUE (),
ISEMPTY ( PersonaPortfolio ),
CALCULATE (
[Delta-P],
FILTER ( fact_DeltaP, NOT ( fact_DeltaP[Portfolio] IN PersonaPortfolio ) )
),
CALCULATE (
[Delta-P],
FILTER ( fact_DeltaP, fact_DeltaP[Portfolio] IN PersonaPortfolio )
)
)
Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!
You can also check out my LinkedIn!
Best regards,
Gonçalo Geraldes
@goncalogeraldes This does get rid of that error. Thank you!
The next level of complexity would be having 2 conditions within that calculate function. Is that a possibility using the same switch function logic?
The IF function can't output tables, only single values, but you could rewrite this more like
SWITCH (
TRUE (),
ISEMPTY ( A ) && ISEMPTY ( B ), CALCULATE ( [Delta-P], IgnoreA, IgnoreB ),
ISEMPTY ( A ) && NOT ISEMPTY ( B ), CALCULATE ( [Delta-P], IgnoreA, FilterB ),
NOT ISEMPTY ( A ) && ISEMPTY ( B ), CALCULATE ( [Delta-P], FilterA, IgnoreB ),
NOT ISEMPTY ( A ) && NOT ISEMPTY ( B ), CALCULATE ( [Delta-P], FilterA, FilterB )
)
@AlexisOlson This worked, thank you!
I have 4 different tables it is referencing, A,B,C, and D. Your example is showing A and B. Due to this, I needed to have 16 of those scenarios listed out in my code. I'm afraid of it getting out of control if I need to add any more tables. Are you familiar with a more concise way to handle this or is the code you provided the only solution?
Yeah, I think you can refactor it to combine FilterA and IgnoreA like this:
Test =
VAR A = CALCULATE ( [...] )
VAR B = CALCULATE ( [...] )
VAR C = CALCULATE ( [...] )
VAR D = CALCULATE ( [...] )
VAR FilterA = FILTER ( fact, IF ( ISEMPTY ( A ), NOT fact[A] IN A, fact[A] IN A ) )
VAR FilterB = FILTER ( fact, IF ( ISEMPTY ( B ), NOT fact[B] IN B, fact[B] IN B ) )
VAR FilterC = FILTER ( fact, IF ( ISEMPTY ( C ), NOT fact[C] IN C, fact[C] IN C ) )
VAR FilterD = FILTER ( fact, IF ( ISEMPTY ( D ), NOT fact[D] IN D, fact[D] IN D ) )
RETURN
CALCULATE ( [Delta-P], FilterA, FilterB, FilterC, FilterD )
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 7 | |
| 6 | |
| 5 |