Forum Discussion

adinarayana123's avatar
adinarayana123
Regular Visitor
5 years ago
Solved

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

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    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.

    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.

2 Replies