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,
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.
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 |
---|---|
104 | |
104 | |
87 | |
73 | |
66 |
User | Count |
---|---|
122 | |
112 | |
98 | |
79 | |
72 |