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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
DataPeter
Frequent Visitor

Standardise Date into Single Occurrences

Hi All

 

Long term reader, first time commenter – love this support forum!

 

Problem: I’m trying to standardise customer records entry dates by occurrence. In short, I want to standardize the first (and subsequent) day of each record irrespective of the specific date/time that has been entered. Table below shows ideal outcome which allow me to group by customers by Day 1, Day2 etc. 

 

Using PowerBI Desktop and data in on one spreadsheet at the moment. Any support would be most appreciated.

 

Customer IDDate/Time StampOutcome
11 April 2020  10amDay 1
11 April 2020 1pmDay 1
12 April 2020 10amDay 2
220 May 2020 9amDay 1
220 May 2020 1pmDay 1
221 May 2020 10amDay 2
320 June 2020 10amDay 1
321 June 2020 10amDay 2

 

cheers

Peter

1 ACCEPTED SOLUTION

@DataPeter - You must have a time component, try:

 

Outcome (Column) =
  VAR __Min = MINX(FILTER('Table',[Customer] = EARLIER([Customer])),[Date/Time Stamp])
RETURN
  "Day " & FLOOR((([Date/Time Stamp] - __Min) * 1. + 1),1)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@DataPeter - Maybe:

Outcome (Column) =
  VAR __Min = MINX(FILTER('Table',[Customer] = EARLIER([Customer])),[Date/Time Stamp])
RETURN
  "Day " & (([Date/Time Stamp] - __Min) * 1. + 1)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler 

 

Thanks for the support, this worked sort of, however it gave me additional decimal places – any thoughts on how to remove these?

 

DataPeter_0-1599452916627.png

 

@DataPeter - You must have a time component, try:

 

Outcome (Column) =
  VAR __Min = MINX(FILTER('Table',[Customer] = EARLIER([Customer])),[Date/Time Stamp])
RETURN
  "Day " & FLOOR((([Date/Time Stamp] - __Min) * 1. + 1),1)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@DataPeter , all

This should give first date as new column

minx(filter(Table, [Customer ID] =earlier([Customer ID])),[Date/Time Stamp])

 

You can have a date diff , and get days
Datediff([Date/Time Stamp],minx(filter(Table, [Customer ID] =earlier([Customer ID])),[Date/Time Stamp]),day)

 

Append Day before

"Day " & Datediff([Date/Time Stamp],minx(filter(Table, [Customer ID] =earlier([Customer ID])),[Date/Time Stamp]),day) 

 

Same this has been dicssued for cohort report creation in this webinar -https://www.youtube.com/watch?v=Q1vPWmfI25o&t=2420s

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.