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.
Hi all,
I'd like to create a DAX column which returns a text value with rules.
I tried with a SWITCH True formula, but (as expected) it didn't work, because the conditions only applies for one row after another. The rules should apply to the column Account with the same value. For example Account = A has three rows. The 3rd row in the new column "defined" should be "Good" as well, because Account A has Category = "Done" in the first two rows.
The same applies to the other marked rows.
Thank you a lot for your help.
Solved! Go to Solution.
@dwilltho27
Add the following code as anew column to your table:
Defined =
IF(
ISEMPTY( FILTER( Accounts , Accounts[Account] = EARLIER(Accounts[Account]) && Accounts[Category] = "Done")),
"In Progress",
"Done"
)
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi,
This calculated column formula works
=if(AND(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[Account]=EARLIER(Data[Account])&&(Data[Category]="Done"||Data[Category]="Unfinished")))=CALCULATE(COUNTROWS(Data),FILTER(Data,Data[Account]=EARLIER(Data[Account]))),CALCULATE(COUNTROWS(Data),FILTER(Data,Data[Account]=EARLIER(Data[Account])&&Data[Category]="Done"))>=1),"Good","In progress")
Hope this helps.
@dwilltho27
Add the following code as anew column to your table:
Defined =
IF(
ISEMPTY( FILTER( Accounts , Accounts[Account] = EARLIER(Accounts[Account]) && Accounts[Category] = "Done")),
"In Progress",
"Done"
)
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi @dwilltho27
take a look at the folowing solution:
Defined =
VAR _Text = CONCATENATEX(VALUES('Table'[Category]),'Table'[Category])
RETURN
SWITCH(TRUE(),
_Text = "Done" , "Good",
_Text = "Unfinished" , "In Progress",
"Good"
)
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
@mahoneypat Thx, but didn't work.
thanks. I tried the same solution, but in my case Account C is still "Good" instead of "In Progress".
What is different in my new column?
Switch True returns the first one that's true. All you need to do is change the order. Put the one with && as the second one.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
User | Count |
---|---|
91 | |
73 | |
68 | |
63 | |
55 |
User | Count |
---|---|
99 | |
88 | |
73 | |
60 | |
58 |