# Period to date Median of a percentage value

Hi I am having issues when using periodtodatemedian with a percentage field (calculated field Y/(X+Y)).

It is giving me an error, here the calculation

ifelse(

\${Periodstarting}=‘Day’, periodToDateMedian({Commitment}, {Adjusted Order Date - C}, ‘DAY’, now()),

\${Periodstarting}=‘Week’, periodToDateMedian({Commitment}, {Adjusted Order Date - C}, ‘WEEK’, now()),

\${Periodstarting}=‘Month’, periodToDateMedian({Commitment}, {Adjusted Order Date - C}, ‘MONTH’, now()),

\${Periodstarting}=‘Quarter’, periodToDateMedian({Commitment}, {Adjusted Order Date - C}, ‘QUARTER’, now()),

periodToDateMedian({Commitment}, {Adjusted Order Date - C}, ‘YEAR’, now()))

Can someone help me understanding what is going on? thanks.

It works for me. You might need to get rid of spacing (don’t know why) and refresh the page and try again.

ifelse(\${Client}=‘Day’, periodToDateMedian({int bearable}, {event_timestamp}, ‘DAY’, now()),\${Client}=‘Week’, periodToDateMedian({int bearable}, {event_timestamp}, ‘WEEK’, now()),\${Client}=‘Month’, periodToDateMedian({int bearable}, {event_timestamp}, ‘MONTH’, now()),\${Client}=‘Quarter’, periodToDateMedian({int bearable}, {event_timestamp}, ‘QUARTER’, now()),periodToDateMedian({int bearable}, {event_timestamp}, ‘YEAR’, now()))

This is mine that is working.

periodToDateMedian({int bearable} - are you using decimals? Cause my {commitment} is a decimal (calculated from other two field in X/(X+Y))

Yes mine is. You’re not aggregating the in commitment field are you?

yes I am, {commitment } is: sum(X)/sum(X+Y)… would it not work if I aggregate?

Yes that won’t work. If you need it to be like such then you will need to transfer that sum(x)/sum(x+y) logic into sql and group down to the fields you want it grouped by.

Or you can try using it without the sums. Although it might be a different calculation than expected.

1 Like

thank you very much for your help!!

1 Like