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.
Hi all
I am trying to make a new column that count the number of occurences contained in another columns strings
My data looks like this (the desired result is marked in yellow)
Thanks in advance
The Best Carsten
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
expected result CC =
VAR _maxnumber =
MAXX (
ADDCOLUMNS (
Data,
"@countdelimiter", LEN ( Data[Path] ) - LEN ( SUBSTITUTE ( Data[Path], "|", "" ) )
),
[@countdelimiter]
) + 1
VAR _generateseriestable =
SELECTCOLUMNS ( GENERATESERIES ( 1, _maxnumber, 1 ), "@number", [Value] )
VAR _t =
GENERATE (
_generateseriestable,
ADDCOLUMNS ( Data, "@item", PATHITEM ( Data[Path], [@number] ) )
)
RETURN
COUNTROWS ( FILTER ( _t, [@item] = EARLIER ( Data[ItemID] ) ) )
Thanks 🙂
Hi,
Please check the below picture and the attached pbix file.
expected result CC =
VAR _maxnumber =
MAXX (
ADDCOLUMNS (
Data,
"@countdelimiter", LEN ( Data[Path] ) - LEN ( SUBSTITUTE ( Data[Path], "|", "" ) )
),
[@countdelimiter]
) + 1
VAR _generateseriestable =
SELECTCOLUMNS ( GENERATESERIES ( 1, _maxnumber, 1 ), "@number", [Value] )
VAR _t =
GENERATE (
_generateseriestable,
ADDCOLUMNS ( Data, "@item", PATHITEM ( Data[Path], [@number] ) )
)
RETURN
COUNTROWS ( FILTER ( _t, [@item] = EARLIER ( Data[ItemID] ) ) )
User | Count |
---|---|
27 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
7 | |
6 |