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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Vibration85
Helper II
Helper II

compare the values of one column, based on the date from another column

Hi everyone,

 

If anyone can help me, how to compare the values of one column, based on the date from another column? I have a column that is included IDs (I have 2 or several IDs per day), I need to find the IDs from each day and put a label for each ID category in another column.

in the below example: I have Run ID which for Oct 15th, I have 4 rows with 2 codes, I wanted to put the label in another column, 60 as the first running, 61 the second running. 

 

Vibration85_0-1602852014594.png

 

 

thanks

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

Hi, @Vibration85 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may create a calculated column as below.

Column = 
var tab =
SUMMARIZE(
    ALL('Table'),
    'Table'[Run ID],
    'Table'[Date]
)
var newtab = 
ADDCOLUMNS(
    tab,
    "Rank",
    var re = 
    COUNTROWS(
        FILTER(
            tab,
            [Date]=EARLIER('Table'[Date])&&
            [Run ID]<EARLIER('Table'[Run ID])
        )
    )+1
    return re&" Running"
)
return
MAXX(
    FILTER(
        newtab,
        [Run ID]=EARLIER('Table'[Run ID])&&
        [Date]=EARLIER('Table'[Date])
    ),
    [Rank]
)

 

Result:

a2.png

 

Best Regards

Allan

 

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

9 REPLIES 9
v-alq-msft
Community Support
Community Support

Hi, @Vibration85 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may create a calculated column as below.

Column = 
var tab =
SUMMARIZE(
    ALL('Table'),
    'Table'[Run ID],
    'Table'[Date]
)
var newtab = 
ADDCOLUMNS(
    tab,
    "Rank",
    var re = 
    COUNTROWS(
        FILTER(
            tab,
            [Date]=EARLIER('Table'[Date])&&
            [Run ID]<EARLIER('Table'[Run ID])
        )
    )+1
    return re&" Running"
)
return
MAXX(
    FILTER(
        newtab,
        [Run ID]=EARLIER('Table'[Run ID])&&
        [Date]=EARLIER('Table'[Date])
    ),
    [Rank]
)

 

Result:

a2.png

 

Best Regards

Allan

 

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

Awesome Allan @v-alq-msft 

 

Many thanks, it was great and exactly what I was looking for. So clean and perfect. 😊 

 

Best regards

shaowu459
Resolver II
Resolver II

Hi, @Vibration85 

 

Check if this is what you need:

let
    Source = Excel.CurrentWorkbook(){[Name="Table16"]}[Content],
    ChangeType = Table.TransformColumnTypes(Source,{"Run_Datetime", type date}),
    Custom1 = Table.Combine(Table.Group(ChangeType,"Run_Datetime",{"n",each Table.AddColumn(_,"Num",(x)=>Text.From(1+List.PositionOf(List.Distinct([Run ID]),x[Run ID]))&" Running")})[n])
in
    Custom1

1.png 

dear @shaowu459 

 

could you give me the DAX code, please?

Thank you so much 🙂 

Sorry, I didn't notice you need DAX code😂 I'm not familiar with DAX, so let's wait for DAX expert to help you.

Thank you so much for your effort 😁

 

by the way, as my time is so limited, could you give me a hint on how to use this M language? 😉

 

I'm not familiar with M lang at all, a dummy on it.

FYI.

1.png2.png3.png4.jpg

Hey dude, apart from everything, I put my efforts and learn how to use it and it did work, many thanks 🙂

Thanks Pal, @shaowu459 

 

It was not working for me, 😁 as I had many changes before this modification in the advance editor and I think a little bit different in code structure with I saw in Power Query advance editor structure. anyway, thanks a lot. Hope anyone can help me with the DAX code. 

 

Cheers

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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