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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.


Go to My LinkedIn Page


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.


Go to My LinkedIn Page


Anonymous
Not applicable

Captura.PNG

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.