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.
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]))
Solved! Go to Solution.
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]
)
)
)
@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] )
)
)
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!! 😄
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |