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
jvm
Frequent Visitor

Conditional Usage of Columns

I've been trying to do something that looks simple but still couldn't find any answers to:

 

I have 2 columns A and B and I'm calculating a measure using both. What should I do if I wanted the user to be able to click a button (or buttons) to make it possible for the measure to be computed for different scenarios according to the button selected, e.g. using:

- only the values of column A or

- only the values of column B or

- both columns

 

Thank you in advance! 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @jvm 

You can create a slicer with the options. A one-column table:

SlicerTable

Option 1 

Option 2

Option 3

The user can then select the option in the slicer.  Your measure would read the contents of the slicer and perfomr the required calculation based on it. Something like:

Measure =
SWITCH (
    SELECTEDVALUE ( SlicerTable[Option] ),
    "Option 1", SUM(Table1[Col A]), 
    "Option 2", SUM(Table1[Col B]),
    "Option 3", SUM(Table1[Col A]) + SUM(Table1[Col B])
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

 

View solution in original post

1 REPLY 1
AlB
Super User
Super User

Hi @jvm 

You can create a slicer with the options. A one-column table:

SlicerTable

Option 1 

Option 2

Option 3

The user can then select the option in the slicer.  Your measure would read the contents of the slicer and perfomr the required calculation based on it. Something like:

Measure =
SWITCH (
    SELECTEDVALUE ( SlicerTable[Option] ),
    "Option 1", SUM(Table1[Col A]), 
    "Option 2", SUM(Table1[Col B]),
    "Option 3", SUM(Table1[Col A]) + SUM(Table1[Col B])
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

 

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.