Forum Discussion
conditional divide
- Anonymous7 years ago
Anonymous - It looks like you're creating WAP as a Calculated Column. It needs to be a Measure. Also, Numerator and Denominator need to be Measures.
Hi Anonymous ,
We can use FILTER function here to get the excepted result.
WAP =
VAR sales =
CALCULATE (
SUM ( 'Master Pricing Data'[Sales] ),
FILTER ( 'Master Pricing Data', 'Master Pricing Data'[Priced/Unpriced] = "Priced" )
)
VAR quantity =
CALCULATE (
SUM ( 'Master Pricing Data'[Quantity] ),
FILTER ( 'Master Pricing Data', 'Master Pricing Data'[Priced/Unpriced] = "Priced" )
)
RETURN
DIVIDE ( sales, quantity )
Regards,
Frank
Thanks for the email. I entered the following function in the calculated Col "WAP"
However, Its still calculating the quantity for "unpriced" row. Please see the example of Ideal roffing as enclosed. P
Excel version Pivot of the background dataWill you suggest to create a helper (dummy column) or kindly suggest if there is somthing incorrect in the manner i have entered the function.
Thanks
- Anonymous7 years agoNot applicable
Anonymous - It's difficult to see what the problem is with your example. Could you supply a dataset, or image of what you're trying to accomplish, including the measure and description of what is wrong with it?
Thanks,
Nathan
- Anonymous7 years agoNot applicable
Hello,
- Please see the interface of my report which I want to achieve.The price/unpriced filter should give WAP only for the quantities which has been Priced. the top-right chart should accordingly show top customers by WAP which has been "priced"
- Please find enclosed the cleaned data excel , for the report above. Col D of the excel tags each entry as priced or unpriced. Please Note Col A for customers. Here, Some quantities for a particular customer (ex. Bai, Col, Ide) is priced while some are unpriced. In such cases the WAP in the final table should calculate WAP only priced quantities (899,1676,1254 respectively). For customers for which every thing is priced (ex. Ken, Kon) it should calculate for total sales/ total quantity (704, 947 respectively). Please , see the desired WAP in Col "I'.
I am not able to attach the working excel. Is it possible to share files. it would be great if you can tell me how to? Meanwhile please see a snaphot of the excel below.
Please let me know if you need more info.
- Anonymous7 years agoNot applicable
Anonymous - The solution that v-frfei-msft provided looks like it should work for your requirement. One thing you could try is to split out the numerator and denominator into 2 additional measures for testing:
WAP Numerator = CALCULATE ( SUM ( 'Master Pricing Data'[Sales] ), FILTER ( 'Master Pricing Data', 'Master Pricing Data'[Priced/Unpriced] = "Priced" ) )
WAP Denominator = CALCULATE ( SUM ( 'Master Pricing Data'[Quantity] ), FILTER ( 'Master Pricing Data', 'Master Pricing Data'[Priced/Unpriced] = "Priced" ) )