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

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.

Reply
Anonymous
Not applicable

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
MFelix
Super User
Super User

Hi @Anonymous ,

 

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

V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

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
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

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.

MFelix
Super User
Super User

Hi @Anonymous ,

 

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



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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