Forum Discussion

afrutos's avatar
afrutos
Icon for Resolver I rankResolver I
4 years ago
Solved

Formula Switch

Hello good morning to all,
I have a question about a formula, let's see if someone can help me. Thank you very much

I am trying to create a measure in which, if I select with my selector the Gross Amount, it calculates the Gross Amount, if I select the Net Amount, it calculates the Net Amount and the same if I select the Taxable Base.
When the value of what I have selected is blank, it automatically puts me (Blank), however, I would like it to put "Nothing pending".

With my formula it is not working

 

 

This is my formula:

Selección Detalle =

IF(ISCROSSFILTERED(Selector[Selección]),

SWITCH(TRUE(),
ISBLANK(VALUES(Selector[Selección])),"Nada pte",
VALUES(Selector[Selección]) = "Importe Bruto", [Bruto],
VALUES(Selector[Selección]) = "Importe Neto", [Importe Neto],
VALUES(Selector[Selección]) = "Base Imponible", [BI NOBLANK] ,
[BI NOBLANK]),
[BI NOBLANK])
 

 Thank you in advanced!

  • afrutos , can you try to print what is coming inside in  MAX ( Selector[Selección] ) like below just to check whether it is going inside correct condtion or not.

    Selección Detalle =
    IF (
        ISCROSSFILTERED ( Selector[Selección] ),
        MAX ( Selector[Selección] )
    )

     

    or try this:-

     

    Selección Detalle =
    VAR selected_value =
        SELECTEDVALUE ( Selector[Selección] )
    RETURN
        IF (
            ISCROSSFILTERED ( Selector[Selección] ),
            SWITCH (
                TRUE (),
                ISBLANK ( selected_value ), "Nada pte",
                selected_value = "Importe Bruto", [Bruto],
                selected_value = "Importe Neto", [Importe Neto],
                selected_value = "Base Imponible", [BI NOBLANK],
                [BI NOBLANK]
            ),
            [BI NOBLANK]
        )

     

10 Replies

  • afrutos , try like

     

    SWITCH(TRUE(),
    ISBLANK((Selector[Selección])),"Nada pte",
    Max(Selector[Selección]) = "Importe Bruto", [Bruto],
    Max(Selector[Selección]) = "Importe Neto", [Importe Neto],
    Max(Selector[Selección]) = "Base Imponible", [BI NOBLANK] ,
    [BI NOBLANK])

    • afrutos's avatar
      afrutos
      Icon for Resolver I rankResolver I

      Hi, it gives me an error: A single value cannot be determined for the 'Selection' column in the 'Selector' table. This can happen when a measurement formula refers to a column containing many values without specifying an aggregation, such as min, max, count or sum, to obtain a single result

       

       

      • ALLUREAN's avatar
        ALLUREAN
        Icon for Solution Sage rankSolution Sage

        Remove one of the double brackets

  • Selección Detalle =

    IF(ISCROSSFILTERED(Selector[Selección]),

    SWITCH(TRUE(),
    ISBLANK(Selector[Selección]),"Nada pte",
    Max(Selector[Selección]) = "Importe Bruto", [Bruto],
    Max(Selector[Selección]) = "Importe Neto", [Importe Neto],
    Max(Selector[Selección]) = "Base Imponible", [BI NOBLANK] ,
    [BI NOBLANK]),
    [BI NOBLANK])
    With this I have the same error
  • I've made it ut I still have the same problem