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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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 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.