Forum Discussion

mmikemcgregor1's avatar
mmikemcgregor1
New Member
3 years ago
Solved

Identifying first rows based on a summed value

Hi all, one more problem. I have a table with a date column, # of hours worked, and our normal price per hour. Usually we charge '$X' per hour but for one client we charge them '$Y' for the first 10 ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  mmikemcgregor1 ,

    Here are the steps you can follow:

    1. In Power query. Add Column – Index Column – From 1.

    2. Create calculated column.

    Rankx =
     RANKX(FILTER(ALL('Table'),
     YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&
     MONTH('Table'[Date])=MONTH(EARLIER('Table'[Date]))),[Index],,ASC)
    Sum =
    SUMX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(EARLIER('Table'[Date]))&&
     MONTH('Table'[Date])=MONTH(EARLIER('Table'[Date]))&&'Table'[Rankx]<=EARLIER('Table'[Rankx])),[Work Hours])
    Need to change Rate/Hr =
    IF(
    'Table'[Sum]<=10,"150","Stay at Normal Rate")

    3. Result:

     

    Best Regards,

    Liu Yang

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