Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am having an issue to calculate percentage rate, tried the below getting error.
Please assist
count(distinct{<[Sub Type]={'Cash'}>,{<Month_Year>} [ID]) / sum({$<[Status]={'Matched'}>}[Transfer_ID]))
want to calculate count of distinct ID when [Sub Type]={'Cash'} for each Month_Year divide by sum(Transfer ID) when Status = Matched.
Thank you,
Richard
Hi @richard24best ,
The first thing you need to do is always ensure that your brackets match up, you have mismatches with {, ) and <.
The Month_Year part of the first set statement is incorrect, as it doesn't have an = sign with it.
If you are trying to get the percentage for each month then the Month_Year should be the dimension in the table or chart, not part of the expression.
To fix the expression so it is valid, you need:
count(distinct {<[Sub Type]={'Cash'}>} [ID]) / sum({<Status={'Matched'}>}[Transfer_ID])
If you want to have a total across all months, but counting the ID in each month it falls you need to use an AGGR statement. Suggest you look up how these work, but in simple terms they allow you to create a virtual table based on a field or number of fields and then perform another operation over that result set.
The syntax would be:
sum(aggr(count(distinct {<[Sub Type]={'Cash'}>} [ID]), Month_Year)) / sum({<Status={'Matched'}>}[Transfer_ID])
Hope that helps.
Steve
Hi @richard24best ,
The first thing you need to do is always ensure that your brackets match up, you have mismatches with {, ) and <.
The Month_Year part of the first set statement is incorrect, as it doesn't have an = sign with it.
If you are trying to get the percentage for each month then the Month_Year should be the dimension in the table or chart, not part of the expression.
To fix the expression so it is valid, you need:
count(distinct {<[Sub Type]={'Cash'}>} [ID]) / sum({<Status={'Matched'}>}[Transfer_ID])
If you want to have a total across all months, but counting the ID in each month it falls you need to use an AGGR statement. Suggest you look up how these work, but in simple terms they allow you to create a virtual table based on a field or number of fields and then perform another operation over that result set.
The syntax would be:
sum(aggr(count(distinct {<[Sub Type]={'Cash'}>} [ID]), Month_Year)) / sum({<Status={'Matched'}>}[Transfer_ID])
Hope that helps.
Steve
Thank you Steve for your explanation and support.
Regards,
Richard