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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cbruhn42
Helper III
Helper III

Need Unique Date Time Field For Moving Average Chart

I have a data set that looks like this:

 

Date / Time    -    Production Order (Unique Value)   -    Brand    -    Phase   -    Value   -    Index   -     Moving Range

 

I sorted the data by phase, brand and production order all ascending and then added an index column so that I can reference the index column when calculating my moving range.

 

My issue is that in my data set the Date / Time column is the date at midnight of that day.  It just defaults to that and is how it's setup in the database. 

 

So when I go to chart the data I sum the value based on the phase and brand.  If there happens to be two rows with the same date, then those values get summed together.  If I add the production order under the date / time field on the x-axis then my average and process limit lines get all wonky.

 

Any thoughts on how I can fix this?  One thing I was thinking is that if I could create a custom column that checks for dupliate date / times and then adds like 1 second to the subsequent date / times so I get a unique time.  In our process we could never start more than 2-3 tanks of the same brand on the same day due to process limitations.

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

Thanks for the reply from amitchandak.

 

Hi @cbruhn42  , 

For you in the last paragraph of the problem description, I created a simple example data and realized the vision that you can apply that date column to the visual according to your own reality, here are my steps:

 

1.Create simple data:

vlinhuizhmsft_0-1724997246483.png

 

2.Create a calculated column:

 

UniqueDateTime =
VAR _CurrentDate = 'Table'[Date / Time]
VAR _RowNumber = 'Table'[Index]
VAR _DuplicateCount =
COUNTROWS(
FILTER(
'Table',
'Table'[Date / Time] = _CurrentDate &&
'Table'[Index] < _RowNumber
)
)
RETURN
IF(_DuplicateCount > 0,
_CurrentDate + TIME( 0,0,_DuplicateCount),
_CurrentDate)

 

3.This achieves the effect of adding 1 to the number of seconds with the same time. 

vlinhuizhmsft_1-1724997300083.png

 

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

2 REPLIES 2
v-linhuizh-msft
Community Support
Community Support

Thanks for the reply from amitchandak.

 

Hi @cbruhn42  , 

For you in the last paragraph of the problem description, I created a simple example data and realized the vision that you can apply that date column to the visual according to your own reality, here are my steps:

 

1.Create simple data:

vlinhuizhmsft_0-1724997246483.png

 

2.Create a calculated column:

 

UniqueDateTime =
VAR _CurrentDate = 'Table'[Date / Time]
VAR _RowNumber = 'Table'[Index]
VAR _DuplicateCount =
COUNTROWS(
FILTER(
'Table',
'Table'[Date / Time] = _CurrentDate &&
'Table'[Index] < _RowNumber
)
)
RETURN
IF(_DuplicateCount > 0,
_CurrentDate + TIME( 0,0,_DuplicateCount),
_CurrentDate)

 

3.This achieves the effect of adding 1 to the number of seconds with the same time. 

vlinhuizhmsft_1-1724997300083.png

 

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

amitchandak
Super User
Super User

@cbruhn42 , Can you try new visual calculation for Moving Avg

Visual Calculations in Power BI- February 2024 Update RUNNINGSUM, RANGE, MOVINGAVERAGE, COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL, FIRST, LAST, PREVIOUS, and NEXT
https://www.youtube.com/watch?v=bKD9T0EWgQo&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

 

You can also consider window function

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f

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
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.