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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Milagros389
Regular Visitor

variable

Milagros389_0-1688679149021.png

 

I have this excel, with those columns. How do I do in power bi to generate a yes/no button, which if (for example) for area1 , I touch yes in amount1 and no in amount2, the total only adds amount1. If I touch yes to both, I add both amounts. I need the button to achieve all the combinations for each area and to be able to select whether in amount1 for area1 and no in amount1 for area2, for example. Thank you

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Milagros389 ,

 

I suggest you to create a calculated table with Area and Importe for slicer.

Slicer =
VAR _TABLE1 =
    ADDCOLUMNS (
        VALUES ( 'Table'[Area] ),
        "AreaOrder", REPLACE ( [Area], 1, 5, "" )
    )
VAR _TABLE2 =
    DATATABLE (
        "Importe", STRING,
        "ImporteOrder", INTEGER,
        {
            { "Importe 1", 1 },
            { "Importe 2", 2 }
        }
    )
RETURN
    GENERATE ( _TABLE1, _TABLE2 )

Measure:

Importe Total =
VAR _Importe1 =
    CALCULATE (
        SUM ( 'Table'[Importe 1] ),
        FILTER (
            'Table',
            'Table'[Area]
                IN CALCULATETABLE ( VALUES ( Slicer[Area] ), Slicer[ImporteOrder] = 1 )
        )
    )
VAR _Importe2 =
    CALCULATE (
        SUM ( 'Table'[Importe 2] ),
        FILTER (
            'Table',
            'Table'[Area]
                IN CALCULATETABLE ( VALUES ( Slicer[Area] ), Slicer[ImporteOrder] = 2 )
        )
    )
RETURN
    _Importe1 + _Importe2

Result is as below.

vrzhoumsft_0-1689059351419.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.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Milagros389 ,

 

I suggest you to create a calculated table with Area and Importe for slicer.

Slicer =
VAR _TABLE1 =
    ADDCOLUMNS (
        VALUES ( 'Table'[Area] ),
        "AreaOrder", REPLACE ( [Area], 1, 5, "" )
    )
VAR _TABLE2 =
    DATATABLE (
        "Importe", STRING,
        "ImporteOrder", INTEGER,
        {
            { "Importe 1", 1 },
            { "Importe 2", 2 }
        }
    )
RETURN
    GENERATE ( _TABLE1, _TABLE2 )

Measure:

Importe Total =
VAR _Importe1 =
    CALCULATE (
        SUM ( 'Table'[Importe 1] ),
        FILTER (
            'Table',
            'Table'[Area]
                IN CALCULATETABLE ( VALUES ( Slicer[Area] ), Slicer[ImporteOrder] = 1 )
        )
    )
VAR _Importe2 =
    CALCULATE (
        SUM ( 'Table'[Importe 2] ),
        FILTER (
            'Table',
            'Table'[Area]
                IN CALCULATETABLE ( VALUES ( Slicer[Area] ), Slicer[ImporteOrder] = 2 )
        )
    )
RETURN
    _Importe1 + _Importe2

Result is as below.

vrzhoumsft_0-1689059351419.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.

 

Milagros389
Regular Visitor

Gracias pero no me sirve esa solucion. de alguna manera tengo que generar la variable para que pueda filtrar cada area y poder poner que si en importe uno y no en importe dos o cualquier combinacion, para cada area y que la media sume donde puse el si. Es muy complicado la verdad y hace semanas vengo buscando una solucion . 

 

Gracias, saludos

Greg_Deckler
Community Champion
Community Champion

@Milagros389 See if the Disconnected Table Trick works as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...

 

Basically, your slicer for area1 and area2 would be your disconnected table and you could construct a measure that adds the correct amounts based on what is chosen.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.