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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX expression - nested Ifs or variables?

UPDATED** I am looking for an efficient way to accomplish the following sudo in DAX measure in Power BI, any help would be appreciated!

 

measure =
If Table1 column1 = "Term1"
Then Table2 Coloum1 * Table3 column1
return value 
 
If returned results > Table1 coloum2
then Table2 Coloum1 * Table3 column1  / Table1 Coloum3
return value
 
If returned results < Table1 coloum2
return "0"
 
 
 
If Table1 column1 = "Term2"
Then Table1 Coloum4 * Table1 Coloum3
return value
  
else if
table1 coloum1 = "Term3"
retun "x"
4 REPLIES 4
Anonymous
Not applicable

Tried Switch True and reeived the following error "swith does not support comparing values of type True/False with values of type Text
 
RequiredTests =

VAR FreqType = SELECTEDVALUE(AccActionOptionRateFreqs[FrequencyType])
Return

SWITCH (
    TRUE(),
FreqType, "Quantity", SUMX(ContractItems, ContractItems[CurrentQuantity]) * SUMX(ContractProjectItemMaterialSetMaterials, ContractProjectItemMaterialSetMaterials[ConversionFactor]),
FreqType, "Contract", SUMX(AccActionOptionRateFreqs, AccActionOptionRateFreqs[ActionRate]) * SUMX(AccActionOptionRateFreqs, AccActionOptionRateFreqs[ActionFrequency]),
FreqType, "Temporal", "x")
 
michellewar_0-1698692987426.png

 

 
Greg_Deckler
Community Champion
Community Champion

@Anonymous Use a SWITCH( TRUE(), ... ) statement



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...
Anonymous
Not applicable

Hi Greg,

 

Thank you for the suggestion, i will research in the SWITCH(TRUE(),..) direction.

 

I updated the sudu for Term1, it was not quite right and is more complicated that the other two terms.  If anyone wants to take a stab at it so i have something to work off of, that would be very appreciated!

Anonymous
Not applicable

I came up with this but my report is not showing all reqults in the measure column, i beleive it is because if the MIN, i tried to use SUMX  but the value is string

 

Measure =


VAR FreqType =
MIN ( AccActionOptionRateFreqs[FrequencyType] )
VAR QuanCalc =
SUMX ( ContractItems, ContractItems[CurrentQuantity] )
* SUMX (
ContractProjectItemMaterialSetMaterials,
ContractProjectItemMaterialSetMaterials[ConversionFactor]
)
VAR ContCalc =
SUMX ( AccActionOptionRateFreqs, AccActionOptionRateFreqs[ActionRate] )
* SUMX ( AccActionOptionRateFreqs, AccActionOptionRateFreqs[ActionFrequency] )
VAR Conver =
SUMX ( ContractItems, ContractItems[CurrentQuantity] )
* SUMX (
ContractProjectItemMaterialSetMaterials,
ContractProjectItemMaterialSetMaterials[ConversionFactor]
)
VAR ActFreq =
SUMX ( AccActionOptionRateFreqs, AccActionOptionRateFreqs[ActionFrequency] )
VAR MinCalc = ( Conver / ActFreq )
RETURN


IF (
FreqType = "Quantity",
QuanCalc,
IF (
QuanCalc
> ( SUMX ( AccActionOptionRateFreqs, AccActionOptionRateFreqs[MinQtyRequired] ) ),
MinCalc,
IF (
QuanCalc
< ( SUMX ( AccActionOptionRateFreqs, AccActionOptionRateFreqs[MinQtyRequired] ) ),
"0",
IF (
FreqType = "Contract", ContCalc,
IF (
FreqType = "Temporal", "x", " " ) )
)
)
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.