Forum Discussion
Incorrect Status based on Minimum value
Hi all,
Am stuck in a situation that I cant seem to solve, still learning so would appreciate if you could tell me what am I doing wrong and how do I get this right? It seems simple, but not for me anymore.
Background: ACME company sells products in various cities and i need to check if ACME is Cheaper, Same or Expensive in terms of pricing. The same product may be sold in 10 different stores in a city and we want to know:
1. How is ACME doing for each product by City or by Store and I calculate that as follows:
For each City:
a. List all the instances of that one product (lets say that product was sold in 10 stores in Dallas,so 10 instances,which means we may have 10 different store prices
b. Then retun the minimum price of these 10 prices
c. Compare this minimum price against the ACME price and determine whether the product is Cheap, Same or Expensive
d. Count the number of Cheap, Same and Expensive products
Formula:
1. Measure to calculate min price = 1 Min Price = CALCULATE(MINX(Data,Data[Store Price]),ALLEXCEPT(Data,Data[Barcode],Data[City],Data[Match Type],Data[Store]))
2. Calculated Column to detrmine status = 2 Price Status = if(Data[ACME Price]<[1 Min Price],"Cheap",if(Data[ACME Price]=[1 Min Price],"Equal","Expensive"))
Problem to be solved:
Screenshot 1 - When i have stores listed along with City, then the formula should consider the Store column and give me minimum price per Store (basically it will do a row by row comparison as a a store will show only once per city) which is what its doing in the "Min Price" and also the status is correct
Screenshot 2 - When I remove stores, the "Min Price" column is showing the right minimum price for a product per city, however the Status is incorrect - for product ending 7572, both the status must be Equal and for product ending 3566, it should be Expensive
Can someone please advise what am I doing wrong? How do i get the status right when viewing by City?
7 Replies
- AnonymousNot applicable
Can someone please assist?
- AnonymousNot applicable
bump
- HotChilliCommunity Champion
If you have a measure and a calculated column here (which I think you do), the column will be static from the moment it is created. The measure will change according to context. I think that you want the Status to reflect changes in the measure (which it can't currently do).
There are two approaches: Make all features you require 'calculated columns' i.e. Min Price Per Store, Min Price Per City, Status v. Price Per Store, Status v. Price Per City. You'll have to go this way if you want to put any of the Status fields in a slicer.
OR
Make the two fields that you created both measures.