The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello,
I simply want the DUPLICATE_INDEX to represent how many of the numbers should be added together from PLANNING. This can't be hardcoded, the length of PLANNING can be 100+ digits and go from 1-999. If theres a better way feel free.
Current Output
DUPLICATE_INDEX, PLANNING, OUTPUT
1, "1,3,1", 131
2, "1,3,1", 131
3, "1,3,1", 131
Expected Output
DUPLICATE_INDEX, PLANNING, OUTPUT
1, "1,3,1", 1 (1)
2, "1,3,1", 4 (1+3)
3, "1,3,1", 5 (1+3+1)
Code:
DAYS_TO_ADD =
VAR DigitsTable =
ADDCOLUMNS(
GENERATESERIES(1, PATHLENGTH([PLANNING])),
"Digit",
VALUE(PATHITEM([PLANNING], [Value]))
)
RETURN SUMX(FILTER(DigitsTable,
[Value] <= [DUPLICATE_INDEX]
),
[Digit]
)
Many Thanks,
Bailey.
Solved! Go to Solution.
Update : I used PowerQuery to get the same result. The code may not be useful, but it did the job.
= Table.AddColumn(#"ADD COMMAS TO PLANNING", "Duplicates", each
let
count = if [PLANNING] = "" then 0 else List.Count(Text.PositionOf([PLANNING], ",", Occurrence.All)) + 1,
dup_index = List.Transform({1..count}, each _)
in
dup_index
)
@BaileyL , Try using below DAX
DAYS_TO_ADD =
VAR DigitsTable =
ADDCOLUMNS(
GENERATESERIES(1, PATHLENGTH([PLANNING])),
"Digit",
VALUE(PATHITEM([PLANNING], [Value]))
)
RETURN
SUMX(
FILTER(
DigitsTable,
[Value] <= [DUPLICATE_INDEX]
),
[Digit]
)
Proud to be a Super User! |
|
Update : I used PowerQuery to get the same result. The code may not be useful, but it did the job.
= Table.AddColumn(#"ADD COMMAS TO PLANNING", "Duplicates", each
let
count = if [PLANNING] = "" then 0 else List.Count(Text.PositionOf([PLANNING], ",", Occurrence.All)) + 1,
dup_index = List.Transform({1..count}, each _)
in
dup_index
)
Hi,
This doesn't seem to work. The output is still 131. Thank you though.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
82 | |
65 | |
53 | |
52 |
User | Count |
---|---|
128 | |
115 | |
80 | |
65 | |
63 |