Вопрос

I have a dataset result that contains graph values but it's contained in an odd format as follows;

[[42016,44969],[{"name":"$41,000/year goal","y":41000}],["",""]]

What I want to do is basically break this data out using something such as Mid() except instead of specifying the exact characters, i want to specify the start after a character and end before next character.

An example is to get the value of "42016" from the data above something like;

=Mid(Fields!LinearReturnData.Value,"[[",",")

essentially saying start after the "[[" characters and end at the next comma. I understand for that first value i could use

=Mid(Fields!LinearReturnData.Value,3,5)

but this data is going to vary and won't always be a five digit number, and i also am going to need the same type of thing for the other values such as breaking out the "44969" and retrieving the value of "41000" as a third data point.

thanks

Это было полезно?

Решение

Try the following :-

For the first number:-

=mid(Fields!ID.Value,3,instr(Fields!ID.Value,",")-3)

For the second number:-

=mid(Fields!ID.Value,instr(Fields!ID.Value,",")+1,instr(Fields!ID.Value,"]")-(instr(Fields!ID.Value,",")+1))

For the third number:-

=mid(Fields!ID.Value,instr(Fields!ID.Value,"""y"":")+4,instr(Fields!ID.Value,"}")-instr(Fields!ID.Value,"""y"":")-4)

They work for the following set of data:-

[[42016,44969],[{"name":"$41,000/year goal","y":41000}],["",""]]
[[4206,144969],[{"name":"$41,000/year goal","y":41000}],["",""]]
[[4204566,69],[{"name":"$41,560,000/year goal","y":41560000}],["",""]]

enter image description here

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top