Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi
I need help with a dax code, i am trying to define my cases in to casegroup and these are the condition.
Hardcase = Type of case = A and info = red and infotype = 1003
Medium case = Type of case = A and info <> red and infotype <> 1003
I need the code to considere muliple lines as you can see because each case can have multiple info and info types.
The result of the casegroup tabel should look like this:
Case nr | Type of case | Info | Infotype | Casegroup |
11 | A | Blue | 1001 | Hard case |
11 | A | Green | 1002 | Hard case |
11 | A | Red | 1003 | Hard case |
12 | A | Blue | 1001 | Medium case |
12 | A | Green | 1002 | Medium case |
Solved! Go to Solution.
Okey... I understand now
Then, you need to define a flag for the row you want to flag
Flag = IF(MyTable[Type of case]="A" && MyTable[Info]="Red" && MyTable[Infotype]="1003", 1,0)
And define the case, if the flag appears at some point of the case nr
Casegroup =
var _chekflag=CALCULATE(MAX(MyTable[Flag]),ALLEXCEPT(MyTable,MyTable[Case nr]))
return if(_chekflag=1,"Hard case","Medium case")
That is the same results i am getting however i want each case to be in on group with this formula a case can be defined as to different groups
Hi @htsvhwave
I supposed to...but: how do you get this groups? The table you have put as example doesn't follow the logic shown above.
I mean, why this case is hard case?
A | Blue | 1001 | Hard case |
If you consider your rules:
Hardcase => Type of case = A (OK) and info = red (NO) and infotype = 1003 (NO) = NO
Medium case => Type of case = A (OK) and info <> red (OK) and infotype <> 1003 (OK)= YES
but as you can see each case has 2-3 lines of info, inmy example i have shown to cases that are case nr 11 and 12, do you have another suggestion on how to solve it, i wanted help to see i i could make a dax code that looked at all the infor for each case nr and not each line
Okey... I understand now
Then, you need to define a flag for the row you want to flag
Flag = IF(MyTable[Type of case]="A" && MyTable[Info]="Red" && MyTable[Infotype]="1003", 1,0)
And define the case, if the flag appears at some point of the case nr
Casegroup =
var _chekflag=CALCULATE(MAX(MyTable[Flag]),ALLEXCEPT(MyTable,MyTable[Case nr]))
return if(_chekflag=1,"Hard case","Medium case")
Hi @htsvhwave
I don't find the logic between your exposition and the table in the example. Following your conditions you will get this:
Casegroup = IF(MyTable[Type of case]="A", IF(MyTable[Info]="Red" && MyTable[Infotype]="1003", "Hard case","Medium case"),"Case")
Anyway, it is easy to modify my formula. Just one thing to take into account... I have put all the types as text. If for example Infotype is a number, just remove the quotes: MyTable[Infotype]=1003