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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
thomazinh
Helper I
Helper I

Multiple What If parameters for same table different rows

I want to use the What If parameter for multiple rows in a table and have different What If parameters for a specific Cost ID types. I'm trying to calculate the Hours/Bid Value or the selected Parameter for the corresponding Bid Factor. For example, for all WbsCodes containing a string of .AAA. I want to use the What If Parameter_AAA instead of the default Bid Value. There are mulitple Cost ID types but I am only needing it for three Cost ID types within the WbsCode. I tried using a SWITCH funciton, but I wasn't able to get it correct. Sample data and DAX are below. 

 

thomazinh_0-1647874695066.png

 

 

 

_Factored =
VAR AAABid =
    SELECTEDVALUE ( Parameter_AAA[Parameter_AAA] ) //Grabbing the selected what if parameter for AAA
VAR BBBBid =
    SELECTEDVALUE ( Parameter_BBB[Parameter_BBB] ) //Grabbing the selected what if parameter for BBB
VAR FFFBid =
    SELECTEDVALUE ( Parameter_FFF[Parameter_FFF] ) //Grabbing the selected what if parameter for FFF
VAR Hours =
    SUM ( Table4[Hours] ) //Sum of Hours
VAR Unfactored =
    DIVIDE ( Hours, SUM ( Table4[Bid Value] ), 0 ) // Unfactored Desired value
// Factored valued returns the selected Parameter for the WbsCode containing that string. For example, Parameter_AAA should only influence WbsCodes with that Trade type.
VAR Result =
    SWITCH (
        CONTAINS ( Table4, Table4[WbsCode], "" ),
        "AAA", DIVIDE ( Hours, AAABid, 0 ),
        "BBB", DIVIDE ( Hours, BBBBid, 0 ),
        "FFF", DIVIDE ( Hours, FFFBid, 0 ),
        Unfactored
    ) //   IF (
//       CONTAINS ( Table4, Table4[WbsCode], ".AAA." ) = ".AAA.",
//       DIVIDE ( Hours / AAABid, 0 ),
//       IF (
//           CONTAINS ( Table4, Table4[WbsCode], ".BBB." ),
//           DIVIDE ( Hours / BBBBid, 0 ),
//           DIVIDE ( Hours, FFFBid, 0 )
//       )
//   )
RETURN
    Result

 

 

 

Or trying this Result DAX 

 

 

VAR Result =
SWITCH (
    TRUE (),
    CONTAINSSTRING ( 'Table4'[WbsCode], ".AAA" ), DIVIDE ( Hours, AAABid, 0 ),
    CONTAINSSTRING ( 'Table4'[WbsCode], ".BBB." ), DIVIDE ( Hours, BBBid, 0 ),
    SEARCH ( ".FFF.", 'Table4'[WbsCode], 1, 0 ) = 1, DIVIDE ( Hours, FFFBid ),
    Unfactored
)

CostID WbsIndex Trade WbsCode Hours Cost BidValue

ALPH1179AAA1179.AAA.10.ALPH56 $  3,666.002.00
BRAV1866BBB1866.BBB.10.BRAV120 $  3,091.001.00
CHAR1799CCC1799.CCC.10.CHAR36 $  2,331.001.00
DELT1010DDD1010.DDD.10.DELT111 $  3,814.002.00
ECHO1650EEE1650.EEE.10.ECHO7 $  2,431.001.00
FOXT1163FFF1163.FFF.10.FOXT158 $  3,370.001.00
ALPH1428AAA1428.AAA.10.ALPH77 $  2,413.002.00
BRAV1055BBB1055.BBB.10.BRAV55 $  2,729.003.00
CHAR1640CCC1640.CCC.10.CHAR12 $  2,531.001.00
DELT1977DDD1977.DDD.10.DELT10 $  2,972.001.00
ECHO1286EEE1286.EEE.10.ECHO45 $  2,808.003.00
FOXT1597FFF1597.FFF.10.FOXT125 $  3,617.001.00
ALPH1563AAA1563.AAA.10.ALPH148 $  2,642.003.00
BRAV1514BBB1514.BBB.10.BRAV132 $  3,903.001.00
CHAR1700CCC1700.CCC.10.CHAR142 $  2,765.002.00
DELT1491DDD1491.DDD.10.DELT43 $  2,271.003.00
ECHO1872EEE1872.EEE.10.ECHO111 $  3,407.001.00
FOXT1629FFF1629.FFF.10.FOXT26 $  2,012.002.00
ALPH1368AAA1368.AAA.10.ALPH16 $  2,559.003.00
BRAV1441BBB1441.BBB.10.BRAV26 $  2,095.001.00
CHAR1319CCC1319.CCC.10.CHAR102 $  3,087.002.00
DELT1750DDD1750.DDD.10.DELT112 $  3,642.002.00
ECHO1780EEE1780.EEE.10.ECHO1 $  3,764.003.00
FOXT1055FFF1055.FFF.10.FOXT26 $  3,748.003.00
ALPH1409AAA1409.AAA.10.ALPH148 $  3,908.003.00
BRAV1513BBB1513.BBB.10.BRAV18 $  3,106.003.00
CHAR1516CCC1516.CCC.10.CHAR72 $  3,856.003.00
DELT1236DDD1236.DDD.10.DELT42 $  3,810.002.00
ECHO1254EEE1254.EEE.10.ECHO144 $  3,929.003.00
FOXT1203FFF1203.FFF.10.FOXT108 $  3,067.001.00

 

1 ACCEPTED SOLUTION

I thought it was a calculated column, not a measure. Try wrapping the Table4[WbsCode] in SELECTEDVALUE

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

Change your switch statement to

SWITCH( TRUE(),
    CONTAINSSTRING( Table4[WbsCode], "AAA"), DIVIDE( Hours, AAABid, 0),
    CONTAINSSTRING( Table4[WbsCode], "BBB"), DIVIDE( Hours, BBBBid, 0),
    CONTAINSSTRING( Table4[WbsCode], "FFF"), DIVIDE( Hours, FFFBid, 0),
    Unfactored
)

thomazinh_0-1647877658466.png 

thomazinh_0-1647878033431.png

 

I'm returning an error "single value for column WbsCode in Table4 cannot be determined...column contains many values... without specifying... a min, max, count, or sum to get a single result." I don't want any of those, but I do need to search in the text string. I'm thinking I'll need to use a CONTAINSTRING or something to get around it? 

 

For more context, here is the link to the PBI file. 

I thought it was a calculated column, not a measure. Try wrapping the Table4[WbsCode] in SELECTEDVALUE

I'm able to get around the error, but it doesn't look like its calculating what I'm needing now. 

 

Keeping all parameters at 1,

thomazinh_0-1647878482078.png

 

vs changing the parameters to various numbers.

thomazinh_1-1647878515076.png

 

EDIT**** The individual Factored values changed, but the Total at the bottom of the table did not change. The proposed solution worked. Is there a reason the Total at the bottom didn't update?

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

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.