cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

dax creating new column using max of group

I have data as below. I want to create the last 2 columns using dax
Calculation as follows -
 
for the c2-max column, for each distinct value in the first column, keep the max value in column c1
for the boolean column, if c2-max column is greater than 0 then 1 else nothing
 
PK       batch       batchstatus      c1       c2-max       boolean
11progress1  
12comp   
13comp   
14comp   
15progress551
21progress1  
22progress2 1
23null33 
31progress1  
32progress2  
33progress331
41progress1  
42progress2  
43progress3  
44progress4  
45progress551
46progress   
2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User V
Super User V

Re: dax creating new column using max of group

Hi @ni_tempe ,

 

Try the following code:

 

c2-max =
IF (
    'Table'[c1       ]
        = CALCULATE (
            MAXX ( 'Table', 'Table'[c1       ] ),
            ALLEXCEPT ( 'Table', 'Table'[PK       ] )
        ),
    'Table'[c1       ]
)
boolean = IF( 'Table'[c2-max] > 0 , 1)

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog:

Power BI em Português





View solution in original post

Highlighted
Microsoft
Microsoft

Re: dax creating new column using max of group

Hi @ni_tempe ,

 

You can also try to operate in the query editor, refer to this sample.

test_dax creating new column using max of group.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Super User V
Super User V

Re: dax creating new column using max of group

Hi @ni_tempe ,

 

Try the following code:

 

c2-max =
IF (
    'Table'[c1       ]
        = CALCULATE (
            MAXX ( 'Table', 'Table'[c1       ] ),
            ALLEXCEPT ( 'Table', 'Table'[PK       ] )
        ),
    'Table'[c1       ]
)
boolean = IF( 'Table'[c2-max] > 0 , 1)

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog:

Power BI em Português





View solution in original post

Highlighted
Microsoft
Microsoft

Re: dax creating new column using max of group

Hi @ni_tempe ,

 

You can also try to operate in the query editor, refer to this sample.

test_dax creating new column using max of group.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors