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
adinarayana123
Regular Visitor

How to calculate dynamic index

Hi,

I have sales of a products at different time points. Now I want to plot the sales in power bi desktop based on index instead of Time as mentioned in the below table:

Calculating index dynamically for diffeent products is a challenge for me. Need your advise on how to achieve this.

 

ProductTimeIndex
Product12018010
Product12018021
Product12018032
Product12018043
Product22018030
Product22018041
Product22018052
Product22018063
Product22018074

 

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

Hi @adinarayana123 

Try this code to build a calculated column in your table.

dynamic Index each product = 
RANKX(FILTER('Table','Table'[Product]=EARLIER('Table'[Product])),'Table'[Time],,ASC,Dense)-1

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @adinarayana123 

Try this code to build a calculated column in your table.

dynamic Index each product = 
RANKX(FILTER('Table','Table'[Product]=EARLIER('Table'[Product])),'Table'[Time],,ASC,Dense)-1

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

amitchandak
Super User
Super User

@adinarayana123 , where is a product in the sample for  "index dynamically for different products"

Please share a better sample if possible

 

I think you need to use rank

For Rank Refer these links - Check for sub Category rank
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

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.