Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi All,
Is there a way of returning text based on a number that I have got e.g. the difference between date(s)?
e.g.
Date 1 | Date 2 | Date Difference | Text |
01/01/2019 | 01/06/2019 | 151 | Exisiting |
12/05/2019 | 01/07/2019 | 50 | New |
01/06/2018 | 31/10/2018 | 152 | Old |
I have tried nested if statements but all I get is that for every customer we have it displays the same text for every date we have, I just want it to return the text based on the records I need.
TIA
Solved! Go to Solution.
create a column:
create a column:
@evandrocunico many thanks, will try this out. I have created a new column already for date diff and this throws out some random numbers, but I think I know where the issue lies.
I will respond once I have had the chance to try it out.
Based on your example and assuming [Date Difference] is a measure this should work.
Text = SWITCH( TRUE(), [Date Difference] = 151, "Existing", [Date Difference] = 50, "New", [Date Difference] = 152, "Old", "Other" )
@jdbuchanan71 Thanks for this, but it then throws out the error of MdxScript(Model) (140,98), 'SWITCH' does not support comparing values of type True/False with values of type text. I dont have any columns or values that are of Ture/False types, so not sure why it wont accept the measure?
TIA
@UK_User123456 , You will need to share your model, the measure works in my test:
@jdbuchanan71see below the screenshots. The data types should are the same, as there are no true/false.
I wanted to be able to say that if the "Date Difference is between a certain number it would return the text I wanted it to display. I have also attached the error message that I receive.
Is your field 'Date Difference Last Gift (By Day)' a measure of a column from a table?
If you want to change the compare you can change to operator in the measure.
Text = SWITCH( TRUE(), [Date Difference] < 50, "New", [Date Difference] < 151, "Existing", [Date Difference] >= 152, "Old", "Other" )
Can you share the nested IF statement that you tried? I dont see any reason as to why a nested if statement wouldnt work here!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
105 | |
88 | |
74 | |
66 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |