How to convert digital signal to analog value
The problem seems to be clear to you: for slow systems a pwm signal can be considered analog, but measuring at higher rates and without a filter reveales the digital nature behind pwm and all you see is either logic high (1023) or low (0).
Possible solutions are:


apply a filter in hardware (LC low-pass)
apply a filter in software (e.g. by calculating a running mean)
attach interrupts to the rising/falling edge of your signal and measure the high/low time to calculate the duty cycle


Which of those options to choose will mainly depend on the PWM frequency you want to measure. For low frequency I recommend option 3 (special cases are duty cycles around 0% and 100% as there are no edges), for higher frequencies I would use option 1/2.