Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello Power BI Noob seeks help with AND statement and text…
This is my data:
What I want to do have some sort of calculated column column that tells me which of the 3 groups the vaccination data fits into.
I have part of this working with numbers
Vac Category =
IF([Months since last Vac] <13,
12,
IF([Months since last Vac] >12,
24,
0)
)
This only tells me if something is less or more that 12 months
What I want to do is more like this:
Vac Category =
IF([Months since last Vac] <13,
“Less than 12 months”,
IF([Months since last Vac] >12 AND <25,
“Between 12 and 24 months”,
“Over 24 months”)
)
It doesnt like the text nor the AND.
Any help would be welcome.
Solved! Go to Solution.
Hi @steambucky
Welcome to the community 🙂
To solve your immediate problem, the syntax for the AND function is AND( <condition 1>, <condition 2> )
Also, it's always best to use preface a column with its table name i.e. TableName[ColumnName], so that columns aren't confused with measures.
So you could write something like this (replace TableName with your actual table name):
Vac Category = IF ( TableName[Months since last Vac] < 13, "Less than 12 months", IF ( AND ( TableName[Months since last Vac] > 12, TableName[Months since last Vac] < 25 ), "Between 12 and 24 months", "Over 24 months" ) )
Another suggestion for a more general solution:
https://www.daxpatterns.com/static-segmentation/
All the best,
Owen 🙂
Hi @steambucky
Welcome to the community 🙂
To solve your immediate problem, the syntax for the AND function is AND( <condition 1>, <condition 2> )
Also, it's always best to use preface a column with its table name i.e. TableName[ColumnName], so that columns aren't confused with measures.
So you could write something like this (replace TableName with your actual table name):
Vac Category = IF ( TableName[Months since last Vac] < 13, "Less than 12 months", IF ( AND ( TableName[Months since last Vac] > 12, TableName[Months since last Vac] < 25 ), "Between 12 and 24 months", "Over 24 months" ) )
Another suggestion for a more general solution:
https://www.daxpatterns.com/static-segmentation/
All the best,
Owen 🙂
You sir. are a legend. Thanks for the help 🙂