Forum Discussion

cris1196's avatar
cris1196
Icon for Helper I rankHelper I
3 years ago
Solved

In a column, calculate a value per group

Hi All. I want to reduce the amount of columns that I currently have. My table has the following format:   Date   User   Store   Cohort Year   Rank   Select Store 01/01/2021   25 ...
  • v-yueyunzh-msft's avatar
    v-yueyunzh-msft
    3 years ago

    Hi , cris1196 

    According to your description, you want to move the rankx column logic to the [Select Sttore] column.

    Here are the steps you can refer to :
    (1)This is my test data:

    (2)We can click "New Column" and enter this:

    Select Sttore_1 = 
    var user =[User]
    var _t =ADDCOLUMNS('Table',"rankx" , RANKX(FILTER('Table', 'Table'[User]=user ), 'Table'[Date],, ASC, Dense))
    var _t2= FILTER(_t ,[User]=user && [rankx]=2)
    return
    MINX(_t2,[Store])

     

    (3)Then we can meet your need , the result is as follows:

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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