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
bigascon
Frequent Visitor

Return a value from a specific row

I feel like this should be easy but I am having trouble.

pretty much what I have is a table with these values:

 

ChallengeID     Progress     UserCount

ABD-5FGD         1200               67

ABD-5FGD          457              150

ACG-HIFR           267                84

ACG-HIFR         3700                35

 

I want to create a new column that returns the userCount that is related to the maximum value of progress for that specific challengeID. In the case above the table should look like this:

 

ChallengeID     Progress     UserCount     NewColumn

ABD-5FGD         1200               67                  67

ABD-5FGD          457              150                  67

ACG-HIFR           267                84                  35

ACG-HIFR         3700                35                  35

 

I don't really even know where to start or if this is even possible. Help would be much appreciated. Thank you!

1 ACCEPTED SOLUTION
jeroendekker
Frequent Visitor

Hi Bigascon,

 

If you need it as a calculated column this should work. I am not sure if it is the fastest way. Maybe somebody has a faster way:)

Usercount max progress =
//calculate maxprogress for challengeid
VAR MAXPROGRESS =
    CALCULATE (
        MAX ( 'example'[Progress] ),
        FILTER (
            'example',
            'example'[ChallengeID] = EARLIER ( 'example'[ChallengeID] )
        )
    ) //calculate usercount for row that contains maxprogress (highest if 2 rows are equal in progress  
VAR USERCOUNT =
    CALCULATE (
        MAXX (
            FILTER ( 'example', 'example'[Progress] = MAXPROGRESS ),
            'example'[UserCount]
        ),
        ALLEXCEPT ( 'example', 'example'[ChallengeID] )
    )
RETURN
    USERCOUNT

View solution in original post

3 REPLIES 3
mahoneypat
Employee
Employee

Please try this column expression

 

NewColumn 2 =
VAR maxthisID =
CALCULATE (
MAX ( Challenge[Progress] ),
ALLEXCEPT ( Challenge, Challenge[ChallengeID] )
)
RETURN
CALCULATE (
MAX ( Challenge[UserCount] ),
ALLEXCEPT ( Challenge, Challenge[ChallengeID] ),
Challenge[Progress] = maxthisID
)
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


jeroendekker
Frequent Visitor

Hi Bigascon,

 

If you need it as a calculated column this should work. I am not sure if it is the fastest way. Maybe somebody has a faster way:)

Usercount max progress =
//calculate maxprogress for challengeid
VAR MAXPROGRESS =
    CALCULATE (
        MAX ( 'example'[Progress] ),
        FILTER (
            'example',
            'example'[ChallengeID] = EARLIER ( 'example'[ChallengeID] )
        )
    ) //calculate usercount for row that contains maxprogress (highest if 2 rows are equal in progress  
VAR USERCOUNT =
    CALCULATE (
        MAXX (
            FILTER ( 'example', 'example'[Progress] = MAXPROGRESS ),
            'example'[UserCount]
        ),
        ALLEXCEPT ( 'example', 'example'[ChallengeID] )
    )
RETURN
    USERCOUNT
mhossain
Solution Sage
Solution Sage

@bigascon 

 

Try this

 

NewColumn = CALCULATE(MAX('Table'[UserCount]),
ALLEXCEPT('Table','Table'[ChallengeID]))
 
Let me know if it helps, please change 'Table' to your table name 🙂

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.