Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply

SWITCH function with two columns

hi everyone, I need help with a formula that I think should use Switch function.

I have this table (Jerarquia de medidas)

Level 1Level 2
TON 
GSV 
OFFTactic
OFFManual
OFFTax

 

And I have in my data base, a formula for each measure: a formula for OFF, TON, GSV, Tactic, Manual and Tax.

So I need a formula that brings for each level,  the corect formula.

So, I developed this:

 

Formula=

VAR KpiList2= SELECTEDVALUE('Jerarquia Medidas'[Level 2])
VAR KpiList1= SELECTEDVALUE('Jerarquia Medidas'[Level 1])
 
RETURN

SWITCH(KpiList2;
"Manual";[Manual]
;"Tactic";[TACTICO]
;"Tax";[Tax]
)
&&
SWITCH(KpiList1;
"TON";[TON]
;"GSV";[GSV Factura])

The problem is that when I create a table with Level 1 and Level 2 and use this formula, it brings only True and False.
 
Any ideas???
 
Thanks!!!!
1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @MariaFlorenciaB 

Try this

Formula = 
VAR KpiList2 = SELECTEDVALUE('Jerarquia Medidas'[Level 2])
VAR KpiList1 = SELECTEDVALUE('Jerarquia Medidas'[Level 1])
RETURN
SWITCH(
    KpiList1;
    "TON"; [TON];
    "GSV"; [GSV Factura];
    SWITCH(
        KpiList2;
        "Manual"; [Manual];
        "Tactic"; [TACTICO];
        "Tax"; [Tax]
    )
)

Regards,
Mariusz

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

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @MariaFlorenciaB 

Try this

Formula = 
VAR KpiList2 = SELECTEDVALUE('Jerarquia Medidas'[Level 2])
VAR KpiList1 = SELECTEDVALUE('Jerarquia Medidas'[Level 1])
RETURN
SWITCH(
    KpiList1;
    "TON"; [TON];
    "GSV"; [GSV Factura];
    SWITCH(
        KpiList2;
        "Manual"; [Manual];
        "Tactic"; [TACTICO];
        "Tax"; [Tax]
    )
)

Regards,
Mariusz

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

@Mariusz Sorry, I only have one problem:

 

If I add the line OFF to the formula:

 

Formula = 
VAR KpiList2 = SELECTEDVALUE('Jerarquia Medidas'[Level 2])
VAR KpiList1 = SELECTEDVALUE('Jerarquia Medidas'[Level 1])
RETURN
SWITCH(
    KpiList1;
    "TON"; [TON];
    "GSV"; [GSV Factura];
"OFF"; [OFF]; SWITCH( KpiList2; "Manual"; [Manual]; "Tactic"; [TACTICO]; "Tax"; [Tax] ) )

 I only see the total number of OFF for the measure OFF and for the measures Manual, Tactic and Tax.

 

Do you know why this happens?

Thanks very much @Mariusz !!

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.