Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
htsvhwave
Helper II
Helper II

Help with dax code

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 nrType of caseInfoInfotypeCasegroup
11ABlue1001Hard case
11AGreen1002Hard case
11ARed1003Hard case
12ABlue1001Medium case
12AGreen1002Medium case
1 ACCEPTED 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")

 

mlsx4_0-1695716160682.png

 

View solution in original post

5 REPLIES 5
htsvhwave
Helper II
Helper II

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?

ABlue1001Hard 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")

 

mlsx4_0-1695716160682.png

 

mlsx4
Memorable Member
Memorable Member

Hi @htsvhwave 

 

I don't find the logic between your exposition and the table in the example. Following your conditions you will get this:

 

mlsx4_0-1695712425167.png

 

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors