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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Adding a Dynamic Calculation

I have the following formula.  It returns the sum of my raw volume columns base on a slicer selection.  

 

I need to add another slicer that has Raw cases and Equivalent Cases.  If the user selects Raw cases- I need to multiple the volume by 1 or do nothing. If the user selects EQ, I need to multiple at the row level, each row in my data set by a field i have in my dataset called "192oz Conversion Factor" . Any help would be great.  Thanks

Selected Period Volume = 
VAR SPVOLUME =
SELECTEDVALUE ( 'Period Select (2)'[Period Selector])
RETURN
SWITCH (
SPVOLUME,
"YTD",SUM('Power BI Output'[YTD Volume]),
"MTD", SUM('Power BI Output'[MTD Volume]),
"2019", Sum('Power BI Output'[2019 Volume]),
"Rolling 13 Weeks", SUM('Power BI Output'[Rolling 13 Week Volume]),
"Pre-Covid W1-W9", SUM('Power BI Output'[Pre Covid First 9 Wks Volume]),
"Prior 4wks", SUM('Power BI Output'[Current 4 Week Volume]),
"Prior 13wks", SUM('Power BI Output'[Current 13 Week Volume]),
"Prior 26wks", SUM('Power BI Output'[Current 26 Week Volume]),
"Prior 52wks", SUM('Power BI Output'[Current 52 Week Volume]))

 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Using another switch and SUMX should get you what you are looking for.  I don't know what the name of the table is where the user selection for "RAW" or "EQ" sits so you will have to update that.

Selected Period Volume Converted =
VAR SPVOLUME = SELECTEDVALUE ( 'Period Select (2)'[Period Selector] )
VAR CONVERSION = SELECTEDVALUE ( 'Conversion Table'[Conversion Rate] )
RETURN
    SWITCH (
        CONVERSION,
        "RAW",
            SWITCH (
                SPVOLUME,
                "YTD", SUM ( 'Power BI Output'[YTD Volume] ),
                "MTD", SUM ( 'Power BI Output'[MTD Volume] ),
                "2019", SUM ( 'Power BI Output'[2019 Volume] ),
                "Rolling 13 Weeks", SUM ( 'Power BI Output'[Rolling 13 Week Volume] ),
                "Pre-Covid W1-W9", SUM ( 'Power BI Output'[Pre Covid First 9 Wks Volume] ),
                "Prior 4wks", SUM ( 'Power BI Output'[Current 4 Week Volume] ),
                "Prior 13wks", SUM ( 'Power BI Output'[Current 13 Week Volume] ),
                "Prior 26wks", SUM ( 'Power BI Output'[Current 26 Week Volume] ),
                "Prior 52wks", SUM ( 'Power BI Output'[Current 52 Week Volume] )
            ),
        "EQ",
            SWITCH (
                SPVOLUME,
                "YTD",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[YTD Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "MTD",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[MTD Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "2019",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[2019 Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Rolling 13 Weeks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Rolling 13 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Pre-Covid W1-W9",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Pre Covid First 9 Wks Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 4wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 4 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 13wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 13 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 26wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 26 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 52wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 52 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    )
            )
    )

 

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Anonymous First, daxformatter.com is your friend! 🙂 Second, if I understand correctly I think the below calculation should work. If not @ me and post sample data and expected output as text. Thanks!

Selected Period Volume =
VAR SPVOLUME =
    SELECTEDVALUE ( 'Period Select (2)'[Period Selector] )
RETURN
  IF(SPVOLUME = "Raw cases",
    SWITCH (
        SPVOLUME,
        "YTD", SUM ( 'Power BI Output'[YTD Volume] ),
        "MTD", SUM ( 'Power BI Output'[MTD Volume] ),
        "2019", SUM ( 'Power BI Output'[2019 Volume] ),
        "Rolling 13 Weeks", SUM ( 'Power BI Output'[Rolling 13 Week Volume] ),
        "Pre-Covid W1-W9", SUM ( 'Power BI Output'[Pre Covid First 9 Wks Volume] ),
        "Prior 4wks", SUM ( 'Power BI Output'[Current 4 Week Volume] ),
        "Prior 13wks", SUM ( 'Power BI Output'[Current 13 Week Volume] ),
        "Prior 26wks", SUM ( 'Power BI Output'[Current 26 Week Volume] ),
        "Prior 52wks", SUM ( 'Power BI Output'[Current 52 Week Volume] )
    ),
    SWITCH (
        SPVOLUME,
        "YTD", SUMX ( 'Power BI Output',[YTD Volume]*[192oz Conversion Factor] ),
        "MTD", SUMX ( 'Power BI Output',[MTD Volume]*[192oz Conversion Factor] ),
        "2019", SUMX ( 'Power BI Output',[2019 Volume]*[192oz Conversion Factor] ),
        "Rolling 13 Weeks", SUMX ( 'Power BI Output',[Rolling 13 Week Volume]*[192oz Conversion Factor] ),
        "Pre-Covid W1-W9", SUMX ( 'Power BI Output',[Pre Covid First 9 Wks Volume]*[192oz Conversion Factor] ),
        "Prior 4wks", SUMX ( 'Power BI Output',[Current 4 Week Volume]*[192oz Conversion Factor] ),
        "Prior 13wks", SUMX ( 'Power BI Output',[Current 13 Week Volume]*[192oz Conversion Factor] ),
        "Prior 26wks", SUMX ( 'Power BI Output',[Current 26 Week Volume]*[192oz Conversion Factor] ),
        "Prior 52wks", SUMX ( 'Power BI Output',[Current 52 Week Volume]*[192oz Conversion Factor] )
    )
  )

 



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...
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Using another switch and SUMX should get you what you are looking for.  I don't know what the name of the table is where the user selection for "RAW" or "EQ" sits so you will have to update that.

Selected Period Volume Converted =
VAR SPVOLUME = SELECTEDVALUE ( 'Period Select (2)'[Period Selector] )
VAR CONVERSION = SELECTEDVALUE ( 'Conversion Table'[Conversion Rate] )
RETURN
    SWITCH (
        CONVERSION,
        "RAW",
            SWITCH (
                SPVOLUME,
                "YTD", SUM ( 'Power BI Output'[YTD Volume] ),
                "MTD", SUM ( 'Power BI Output'[MTD Volume] ),
                "2019", SUM ( 'Power BI Output'[2019 Volume] ),
                "Rolling 13 Weeks", SUM ( 'Power BI Output'[Rolling 13 Week Volume] ),
                "Pre-Covid W1-W9", SUM ( 'Power BI Output'[Pre Covid First 9 Wks Volume] ),
                "Prior 4wks", SUM ( 'Power BI Output'[Current 4 Week Volume] ),
                "Prior 13wks", SUM ( 'Power BI Output'[Current 13 Week Volume] ),
                "Prior 26wks", SUM ( 'Power BI Output'[Current 26 Week Volume] ),
                "Prior 52wks", SUM ( 'Power BI Output'[Current 52 Week Volume] )
            ),
        "EQ",
            SWITCH (
                SPVOLUME,
                "YTD",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[YTD Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "MTD",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[MTD Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "2019",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[2019 Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Rolling 13 Weeks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Rolling 13 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Pre-Covid W1-W9",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Pre Covid First 9 Wks Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 4wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 4 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 13wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 13 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 26wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 26 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    ),
                "Prior 52wks",
                    SUMX (
                        'Power BI Output',
                        'Power BI Output'[Current 52 Week Volume] * 'Power BI Output'[192oz Conversion Factor]
                    )
            )
    )

 

@jdbuchanan71 Apparently that message took me 4 minutes to write!! 😄



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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.