Forum Discussion
Sum measure based on another measure value
I have created a measure for the "live month number" of a client in our DB. This is an integer value that, for any selected month and client, will inform how many months the client has been live with one of our products.
I then want to sum the revenue generated by that client for a specific month, in this case number 4, and always return that value, regardless of which month is selected or shown. The code is below:
Anonymous and az38, thanks for your help and apologies for the delay in reply. In the end, attempting to do it through a measure proved too difficult and time consuming, so I simply added a calculated column to the relevant table. I will revisit at some stage in the future, as I believe the calculated column is causing a fairly large strain on my dataset, but, for now, I've delivered against my objective so can leave it for a bit.
10 Replies
- az38
Community Champion
Hi tjhoolahan
try
Measure = var _lm = [Live Month] RETURN CALCULATE([Revenue],all('Date'),_lm = 4)do not hesitate to give a kudo to useful posts and mark solutions as solution
- tjhoolahan
Helper I
az38 - it still gives me an error, as per the image below. Am I doing something wrong? Are you expecting this to work because you are making it a variable (this is still a relatively new concept in PBI to me)?
- az38
Community Champion
sorry. try
Measure = var _lm = [Live Month] RETURN CALCULATE([Revenue],filter(all('Date'),_lm = 4))do not hesitate to give a kudo to useful posts and mark solutions as solution
- tlaurindoNew Member
Probably you just need to make a small fix in the formula and it will work. Try this:
CALCULATE([Revenue],FILTER([Live Month],4,all('Date')))
or
CALCULATE([Revenue],IF([Live Month]=4))
- AnonymousNot applicableHm... I've been trying to understand what you need... but kill me - no chance.
Maybe if you were more explicit and give some examples, it would make it digestible.
Best
D- tjhoolahan
Helper I
Anonymous and az38, thanks for your help and apologies for the delay in reply. In the end, attempting to do it through a measure proved too difficult and time consuming, so I simply added a calculated column to the relevant table. I will revisit at some stage in the future, as I believe the calculated column is causing a fairly large strain on my dataset, but, for now, I've delivered against my objective so can leave it for a bit.