Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

New Measure to get value from max id

Hello,

 

I´m trying to create a new measure to calculate the value of Sales from max ID when I filter a date.

For example, if i have the next table:

IDPRODUCTSALESDATE
1110001/01/2021
2220002/01/2021
3165503/01/2021
4212204/01/2021
537505/01/2021
6465807/01/2021
7515807/01/2021
8412307/01/2021
9545607/01/2021

 

If I filter the date with a slicer (for example 02/01/2021-07/01/2021). The result should be the next:

PRODUCTIDSALES_MEASURE
1655
2122
375
4123
5456

 

I´m trying to resolve this with the next measure, but the result is not correct

SALES_MEASURE = CALCULATE(MAX(TABLE[SALES]), FILTER(TABLE, TABLE[ID] = CALCULATE(MAX(TABLE[ID]))))

 

Can you help me¿?

 

Thaaanks a lot!!!!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

 

Picture3.png

 

Sales Measure =
VAR maxid =
MAX ( 'Table'[ID] )
RETURN
SUMX ( FILTER ( 'Table', 'Table'[ID] = maxid ), 'Table'[SALES] )

 

https://www.dropbox.com/s/8cxibhomohn74x6/jmfreire.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

 Hi, @Anonymous 

 

Try to create a measure below:

 

_Switch =
VAR _maxID =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[PRODUCT] <= MAX ( 'Table'[PRODUCT] ) ),
        'Table'[ID]
    )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[ID] ) = _maxID, 1, 0 )

 

Then filter the items when _Switch is 1 like result below

Sample:

v-angzheng-msft_0-1620296564828.jpeg

Result:

v-angzheng-msft_1-1620296564833.jpeg

Please refer to the attachment below for details

 

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

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

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

 

Picture3.png

 

Sales Measure =
VAR maxid =
MAX ( 'Table'[ID] )
RETURN
SUMX ( FILTER ( 'Table', 'Table'[ID] = maxid ), 'Table'[SALES] )

 

https://www.dropbox.com/s/8cxibhomohn74x6/jmfreire.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Captura.PNG

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.