Forum Discussion

filipe197's avatar
filipe197
Frequent Visitor
8 years ago
Solved

How to use button to modify measure

Hello,

I want to set a measure (i will call it Rate) but i wanna somehow link it to a button that could consider or not one of the parcels (or set it to zero). In the example below the measure is the formula for "Rate" ant the button would consider or not the parcel of Manual movements according the user will. Hou can i do this??

Rate = (Costs + Manual movements)/Income

Customer Costs Manual Movements Income
1 10 2 50
2 20 5 70
3. 30 10 100
Sum. 60 17 220

Button YES - considering manual movements
NO - Not considering manual movements

Result:

Yes - =(60+17)/220
No - =60/220
  • Hi filipe197,

     

    There is a slicer visual in Power BI rather than a button. You can try it in this file.

    1. An independent table Buttons.

    Yes

    No

    2. A measure.

    Result =
    IF (
        HASONEVALUE ( Buttons[Button] ),
        IF (
            VALUES ( Buttons[Button] ) = "Yes",
            DIVIDE (
                SUMX ( 'Table1', 'Table1'[Costs] + Table1[Manual Movements] ),
                SUM ( Table1[Income] ),
                0
            ),
            DIVIDE ( SUM ( Table1[Costs] ), SUM ( Table1[Income] ), 0 )
        ),
        BLANK ()
    )

    How_to_use_button_to_modify_measure

     

    Best Regards,

    Dale

2 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi filipe197,

     

    There is a slicer visual in Power BI rather than a button. You can try it in this file.

    1. An independent table Buttons.

    Yes

    No

    2. A measure.

    Result =
    IF (
        HASONEVALUE ( Buttons[Button] ),
        IF (
            VALUES ( Buttons[Button] ) = "Yes",
            DIVIDE (
                SUMX ( 'Table1', 'Table1'[Costs] + Table1[Manual Movements] ),
                SUM ( Table1[Income] ),
                0
            ),
            DIVIDE ( SUM ( Table1[Costs] ), SUM ( Table1[Income] ), 0 )
        ),
        BLANK ()
    )

    How_to_use_button_to_modify_measure

     

    Best Regards,

    Dale