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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
arajan111
Frequent Visitor

DAX formula to create a table which has max attempts for each user and returns responses

Hi,

 

I have a Table imported via spreadsheet which has the following columns:

User IDUser NameAttemptResponse 1Response 2Response 3Response 4
123Fish1PerformingAdoptingPerformingExploring
123Fish2ExploringExploringPerformingExploring
321Chips2ExplorinExplorinExplorinExploring
456KFC2ExploringAdoptingPerformingExploring
456KFC3ExploringPerformingPerformingPerforming

 

How can I use a DAX formula to give me the resultant table:

User IDUser NameAttemptResponse 1Response 2Response 3Response 4
123Fish2ExploringExploringPerformingExploring
321Chips2ExplorinExplorinExplorinExploring
456KFC3ExploringPerformingPerformingPerforming

 

1 ACCEPTED SOLUTION
Shreeram04
Resolver III
Resolver III

Hi @arajan111 ,

 

Please create a calculated column that acts as a flag.

 

Refer below screenshot and Dax for your reference.

 

Max_Attempt_Flag =
VAR MaxAttempt = CALCULATE(MAX('Table'[Attempt]), ALLEXCEPT('Table', 'Table'[User ID]))
RETURN
IF('Table'[Attempt] = MaxAttempt, 1, 0)

Shreeram04_0-1712049931856.png

Shreeram04_0-1712050108742.png

 

If this post helps, please consider accept as solution to help other members find it more quickly.

 

Thanks,

Hari R

 

View solution in original post

2 REPLIES 2
Musadev
Resolver III
Resolver III

Hi @arajan111 
I have created the table, filtering the data by a calculated column.
Create a copy of the table and then add the below measure,  into the table.

Filter out the Rows where you are getting Max value in the new calculated column.  

 

 

Max Value =
VAR MaxResponse =
    CALCULATE (
        MAX ( 'tbl_Creation'[Attempt] ),
        ALLEXCEPT ( 'tbl_Creation', 'tbl_Creation'[User ID] )
    )
RETURN
    IF ( 'tbl_Creation'[Attempt] = MaxResponse, "Max", "" )

 

 

Musadev_0-1712050237040.png

 

 

 

Shreeram04
Resolver III
Resolver III

Hi @arajan111 ,

 

Please create a calculated column that acts as a flag.

 

Refer below screenshot and Dax for your reference.

 

Max_Attempt_Flag =
VAR MaxAttempt = CALCULATE(MAX('Table'[Attempt]), ALLEXCEPT('Table', 'Table'[User ID]))
RETURN
IF('Table'[Attempt] = MaxAttempt, 1, 0)

Shreeram04_0-1712049931856.png

Shreeram04_0-1712050108742.png

 

If this post helps, please consider accept as solution to help other members find it more quickly.

 

Thanks,

Hari R

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.