The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello, Guys!
Two little questions for you:
1. How can I calculate on Power Bi a new column that count previous occurrences, based on ID number, of a name from another column?
Example:
2. Also, how can I create a column (D) that brings a specific attribute (Position now) from only the last occurrence of a name?
Example:
Thanks a lot!
Solved! Go to Solution.
Try this
Previous Occurrences = CALCULATE ( COUNTROWS ( TableName ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[ID] <= EARLIER ( TableName[ID] ) ) ) - 1
And this
Last Position = VAR previousID = CALCULATE ( MAX ( TableName[ID] ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[ID] < EARLIER ( TableName[ID] ) ) ) RETURN CALCULATE ( SUM ( TableName[Position Now] ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[ID] = previousID ) )
Try this
Previous Occurrences = CALCULATE ( COUNTROWS ( TableName ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[ID] <= EARLIER ( TableName[ID] ) ) ) - 1
And this
Last Position = VAR previousID = CALCULATE ( MAX ( TableName[ID] ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[ID] < EARLIER ( TableName[ID] ) ) ) RETURN CALCULATE ( SUM ( TableName[Position Now] ), FILTER ( ALLEXCEPT ( TableName, TableName[Name] ), TableName[ID] = previousID ) )
It worked beautifully! Many many thanks!