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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
afrutos
Resolver I
Resolver I

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])
 

afrutos_0-1642412622250.png

 Thank you in advanced!

1 ACCEPTED SOLUTION

@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]
    )

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

10 REPLIES 10
afrutos
Resolver I
Resolver I

I've made it ut I still have the same problem

afrutos
Resolver I
Resolver I

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
amitchandak
Super User
Super User

@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])

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

 

afrutos_1-1642415618160.png

 

Remove one of the double brackets

afrutos_1-1642415618160.png




Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




I modifyed it,  but still have the same text error

afrutos_1-1642509242299.png

 

@afrutos Small correction in your code. Please use like this:-

Selección Detalle =
IF (
    ISCROSSFILTERED ( Selector[Selección] ),
    SWITCH (
        TRUE (),
        ISBLANK ( MAX ( 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]
)

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi, thank you in advanced.
I made it, but still not working...

afrutos_0-1642510252818.png

This is getting me crazy.

 

@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]
    )

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi,

Now iw working perfectly, ut I don't understand anything, 
Why is working by defining a variable?

Thank you in advanced

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.