cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pbeeyeqs
Helper I
Helper I

Figure TOP and BOTTOM 10 PERCENT

 

Data can be found here: https://www.dropbox.com/s/mz6ev4msk8ntop1/pbi_Example.xlsx?dl=0 

 

Have a list of PRODUCT IDS with Product Name, Date and Price.

 

Would like to know how I can import an excel file and find the TOP 10 Percent Increases AND the BOTTOM 10 Percent Increases from the product IDs in the list. 

 

It would need to look at the price on 10/23/19 and the price on 9/18/19 to figure the price increase. If the 9/18/19 price isn't included, it would not be part of the TOP 10

 

For BOTTOM 10, it would look at the same dates. 

 

Then, if possible, create a new column to put the rank for each product ID. Could be T1, T2, T3, .... B1, B2, B3....

 

 

 

Thanks

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

HI, @pbeeyeqs 

Based on my research, you could try this way as below:

Step1:

Create a measure for Percent Increases

price increase = var _currentdate=CALCULATE(MAX('Table'[DATE]),ALLSELECTED('Table')) return
var _lastdate=CALCULATE(MAX('Table'[DATE]),FILTER(ALLSELECTED('Table'),'Table'[DATE]<_currentdate))return
var _currentprice=CALCULATE(SUM('Table'[PRICE]),FILTER('Table','Table'[DATE]=_currentdate)) return
var _lastprice=CALCULATE(SUM('Table'[PRICE]),FILTER(ALLSELECTED('Table'[DATE]),'Table'[DATE]=_lastdate)) return
	CALCULATE(DIVIDE(CALCULATE(SUM('Table'[PRICE]),FILTER('Table','Table'[DATE]=_currentdate)) - _lastprice, _lastprice))

Step2:

Create the rank measure for desc and asc

RankDESC = RANKX(ALL('Table'[PRODUCT NAME],'Table'[PRODUCT]),[price increase],,DESC)
RankASC = RANKX(ALL('Table'[PRODUCT NAME],'Table'[PRODUCT]),[price increase],,ASC)

 Step3:

Create the conditional output

Result = IF([RankDESC]<=10,"T"&[RankDESC],IF([RankASC]<=10,"B"&[RankASC]))

Result:

8.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

HI, @pbeeyeqs 

Based on my research, you could try this way as below:

Step1:

Create a measure for Percent Increases

price increase = var _currentdate=CALCULATE(MAX('Table'[DATE]),ALLSELECTED('Table')) return
var _lastdate=CALCULATE(MAX('Table'[DATE]),FILTER(ALLSELECTED('Table'),'Table'[DATE]<_currentdate))return
var _currentprice=CALCULATE(SUM('Table'[PRICE]),FILTER('Table','Table'[DATE]=_currentdate)) return
var _lastprice=CALCULATE(SUM('Table'[PRICE]),FILTER(ALLSELECTED('Table'[DATE]),'Table'[DATE]=_lastdate)) return
	CALCULATE(DIVIDE(CALCULATE(SUM('Table'[PRICE]),FILTER('Table','Table'[DATE]=_currentdate)) - _lastprice, _lastprice))

Step2:

Create the rank measure for desc and asc

RankDESC = RANKX(ALL('Table'[PRODUCT NAME],'Table'[PRODUCT]),[price increase],,DESC)
RankASC = RANKX(ALL('Table'[PRODUCT NAME],'Table'[PRODUCT]),[price increase],,ASC)

 Step3:

Create the conditional output

Result = IF([RankDESC]<=10,"T"&[RankDESC],IF([RankASC]<=10,"B"&[RankASC]))

Result:

8.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

amitchandak
Super User
Super User

Assuming you two dates in the slicer. You can try like this.

 

Diff = ( 
VAR _Cuur_start = Minx('Date','Date'[Date]) 
VAR _Curr_END =  Maxx('Date','Date'[Date]) 
return 
if (not(isblank(calculate(Avg(Sales[Sales price]),Sales[Sales Date] = _Cuur_start ))),
calculate(Avg(Sales[Sales price]),Sales[Sales Date] = _Cuur_start )
calculate(Avg(Sales[Sales price]),Sales[Sales Date] = _Curr_END ),null
)
)

 

 

then you can use the top-bottom filter.

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!