Forum Discussion
Use an IF on a column containing string value that if it returns true, returns a number
Hi ChrisMcHugh ,
If I took your question correctly then I think you could try below code:-
IF (
VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] = "LOADED"
&& VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] <> "PARTIALLY LOADED"
&& VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] <> "FAILED"
&& VW_STAGING_TO_ACQ_LOAD_DETAIL[TABLE_NAME] = "ROUTES",
0
)
BR,
Samarth
Hi Samarth,
Yes it is along those lines for definite. However, upon trying your code, this is the error I am getting.
Is there any way to work around this as I am directly pulling from a column in a dataset
- Samarth_184 years ago
Community Champion
ChrisMcHugh Please update it as:-
IF ( MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] ) = "LOADED" && MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] ) <> "PARTIALLY LOADED" && MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] ) <> "FAILED" && MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[TABLE_NAME] ) = "ROUTES", 0 )- ChrisMcHugh4 years ago
Helper I
Yes it seems to be working to some extent! I will have to nest IF and IFELSE for different conditions but the basics of it are correct, thank you
- ChrisMcHugh4 years ago
Helper I
Hi Samarth_18 upon further investigation, I realised this is not quite the solution as it does not return the true value for me, essentially what I have is set it to 0 and then I have formatted a button so that if the measure is 0, to colour the button green yet it is leaving the colour blank and when I set 0 as the false expression also, it then colours the button, I do not think it is reading the max correctly, I am unsure though
- Samarth_184 years ago
Community Champion
ChrisMcHugh you could break down the measure and return the required value, to check if we are getting expected values or not. or you could share your PBIX file after removing sensitive data.
- ChrisMcHugh4 years ago
Helper I