Pivoting data to and from value and indexes