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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors