The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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!