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
bhelou
Responsive Resident
Responsive Resident

If Condition ( text and value )

Dear ,

 

Kindly please correct me this measure in a column : ( it is returning the value of the text combined   ReceivedIssued or RecievedReceived for the inventory )

Material_Status =
IF (
    XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE] = "Account alias"
        && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] < 0,
    "Issued",
    "Received"
)
    IF (
        XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE] = "Inventory"
            && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] < 0,
        "Issued",
        "Received"
    )


Thank you for your help 
Best Regards,

1 ACCEPTED SOLUTION

@bhelou Something along the lines of:

Material_Status =
SWITCH(TRUE(),
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]= "Account alias" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value]<0,"Issued",
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]= "Account alias" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value]>=0,"Received",
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]="Inventory" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] <0,"Issued",
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]="Inventory" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] >=0,"Received",
"Unknown"
)

You can just keep tacking on logical conditions to your heart's content.



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

View solution in original post

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

@bhelou Try:

Material_Status =
IF(
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]= "Account alias",
    IF(XX_AWPT_MTL_MATERIAL_TRX[Net_Value]<0,"Issued","Received"),
    IF(XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]="Inventory" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] <0,"Issued","Received")
)


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

Great it worked  for 2 conditions , now i have multiple conditions in the source type : i tried the same with && it gave me for the purchase orders : Received from ProjectReceived



Material_Status =
IF(
XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]= "Account alias",
IF(XX_AWPT_MTL_MATERIAL_TRX[Net_Value]<0,"Issued","Received"),
IF(XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]="Inventory" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] <0,"Issued from Project","Received from Project"))

&
IF(
XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE] = "Purchase order",
IF(XX_AWPT_MTL_MATERIAL_TRX[Net_Value]<0,"Issued","Received"),
"Received"
)


 Many Thanks @Greg_Deckler 

@bhelou Use SWITCH(TRUE(), ...)

SWITCH function (DAX) - DAX | Microsoft Docs

 

Nested IF's are awful.



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

Okay ill try to use switch , Please can you show me a sample of my dax how to use it ?

Many Thanks @Greg_Deckler 

@bhelou Something along the lines of:

Material_Status =
SWITCH(TRUE(),
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]= "Account alias" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value]<0,"Issued",
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]= "Account alias" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value]>=0,"Received",
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]="Inventory" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] <0,"Issued",
  XX_AWPT_MTL_MATERIAL_TRX[SOURCE_TYPE]="Inventory" && XX_AWPT_MTL_MATERIAL_TRX[Net_Value] >=0,"Received",
"Unknown"
)

You can just keep tacking on logical conditions to your heart's content.



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

Thank you worked very good .

T

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.