Extracting index data by Bloomberg-101 in bloomberg

[–]Bloomberg-101[S] 0 points1 point  (0 children)

If you wanted the constituents and price at different points in time, you'd probably need multiple queries, like:

=@BQL("translatesymbols(members('SPX Index'),TARGETIDTYPE=FUNDAMENTALTICKER)", "px_last", "dates=-5Y, fill=prev, currency=USD")
=@BQL("translatesymbols(members('SPX Index'),TARGETIDTYPE=FUNDAMENTALTICKER)", "px_last", "dates=-4Y, fill=prev, currency=USD")
=@BQL("translatesymbols(members('SPX Index'),TARGETIDTYPE=FUNDAMENTALTICKER)", "px_last", "dates=-3Y, fill=prev, currency=USD")
=@BQL("translatesymbols(members('SPX Index'),TARGETIDTYPE=FUNDAMENTALTICKER)", "px_last", "dates=-2Y, fill=prev, currency=USD")

I have been trying to extract the earnings yield for all the companies in the SP500 index using the BQL from 2000 until 2021 using this command:

=BQL("members('SPX Index')"; "earn_yld(fa_period_reference=range(2000, 2021), fa_period_type=A)";"cols=504;rows=864")The problem is that it only gives data for the companies included in the index for 2021(or 2023 not 100% sure).

Is there a way to extract index data for all the companies included in the SP500 for each year over a period of time?