cancel
Showing results for
Did you mean:
Frequent Visitor

## Last top N value of every column

Hi everyone,

I have 2 different date and calculate week numbers for these. (In second image)

I want to show last 3 values of every column. (In first image)

1 ACCEPTED SOLUTION
Community Support

Sorry for my mistake, the measure of “rank” should be corrected as below:

Measure =

var _rank=SUM('Table'[value])

var ran = RANKX(ALLSELECTED('Table'[Column]),CALCULATE(Max('Table'[Column])),,ASC,Dense)

var a = IF(_rank <>BLANK(),ran,BLANK())

return a

The function I marked bold should be modified to “Max”, not “Sum”.

And you will finally see as below:

Sorry again and hope this time would help.

Best Regards,

Kelly

7 REPLIES 7
Frequent Visitor

Hi, I would like to create a table with week columns where I have to show the last 4 values of every column, the values are comming from a measure. How can I do that, please? I used your two measures posted here in my solution and visaulize the data in a matrix. The matrix show me now the values in "waterfall" form, but I need to see the last 4 values in 4 rows to be abble to make row totals like average, min, max, etc. Can you share the result, please? The link for .pbix in this post is not working for me.

Community Support

Hi @ekarakasli

What you need is to create 2 measures:

1. set a rank according to the first column:

Measure =

var _rank=SUM('Table'[value])

var ran = RANKX(ALLSELECTED('Table'[Column]),CALCULATE(SUM('Table'[Column])),,ASC,Dense)

var a = IF(_rank <>BLANK(),ran,BLANK())

return a

2. get the last 3 values according to the rank.

Measure 2 =

var a =MAXX(ALLSELECTED('Table'[Column]),[Measure])

var b = a-2

return

IF([Measure] >=b && [Measure]<=a,SUM('Table'[value]),BLANK())

With the 2 measures, you will see as below:

You can find the related .pbix file using the following URL:  https://wicren-my.sharepoint.com/:u:/g/personal/michael_wicren_onmicrosoft_com/EZzHKKuBdSpEp5FrMY8lc...

Hope it would help.

Best Regards,

Kelly

Frequent Visitor

Hi, I can not reach the file. Can you share some result pictures, please?

Community Support

Hi  @e-wei ,

This case is closed,could you pls create a new case in our forum?

Best Regards,

Kelly

Frequent Visitor

This measure don't give same values every colum.

When i try your mesure on my date, I have some situation again.

Do you have another alternative or solution for this ?

Community Support

Sorry for my mistake, the measure of “rank” should be corrected as below:

Measure =

var _rank=SUM('Table'[value])

var ran = RANKX(ALLSELECTED('Table'[Column]),CALCULATE(Max('Table'[Column])),,ASC,Dense)

var a = IF(_rank <>BLANK(),ran,BLANK())

return a

The function I marked bold should be modified to “Max”, not “Sum”.

And you will finally see as below:

Sorry again and hope this time would help.

Best Regards,

Kelly

Frequent Visitor

It's working. Thank you so much for your support.

Best Regards

Enes

Announcements

#### Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

#### Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

#### What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

#### Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors
Top Kudoed Authors