Time calculation errors — suggestions?
-
Time calculation errors — suggestions?
Posted by DSC Communities on April 29, 2020 at 6:17 pm-
Eric Rosen
MemberApril 29, 2020 at 6:17 PM
I have a general ledger history table with:Ā GL Account Number;Ā Month in Year (eg Jan 2020); Fiscal Year, Location and Amount.Ā Ā I can create measures using all the standard functions–sum, sumx, etc on the Amount and the measures work.Ā Ā However, when I link to a Date table to perform time calculations (Feb 2020 vs Feb 2019 totals by location, for example) I CANNOT get the time calcs to work.Ā Ā Ā
I’ve followed various online videos and learnings, using both SAMEPERIODLASTYEAR and DATEADD functions–nothing ‘moves’ the date to show the prior period’s amounts.Ā Ā I have marked the Date table as a “Date Table”, joined the tables using any combination of Date and/or text fields.Ā Ā
And I’ve created new columns that show each date in February (for example) with a “month column’ of Feb 1st….
At my wit’s end–can anyone suggest why joining the Date table, which has records/dates for each day, cannot link to the GL table which has monthly amounts?Ā
Thanks in advance.——————————
Eric Rosen
IT Manager
—————————— -
Audrey Abbey
MemberApril 29, 2020 at 7:49 PM
Eric,ĀCan you post some sample data in Excel?
And possibly your DAX formulas?
And example of your date table, and an example of your GL table with dummy data would be ideal.ĀYour date table has a list of dates like 1/1/2020,1/2/2020, correct?
Does it have any future dates in it? (This is a sneaky thing about the build in time functions like SAMEPERIODLASTYEAR)
Does your GL table also have a date column in the same format (1/1/2020, 2/1/2020)?Ā
Do you have a relationship created between GL And Dates? Which columns did you connect on?
Do either of the date columns have a time portion?ĀAnd can you expand on what results you are getting?
Is it showing a blank?
Is it showing a value that makes no sense?
Is it showing a value that you know is incorrect?
Are you getting an error?——————————
Audrey Abbey
SR. BI Developer/Analyst
LeapFrogBI
Portland OR
——————————
——————————————- -
Christopher Schnaars
MemberApril 30, 2020 at 8:02 AM
Hi, Eric:I’ll just throw this out there because it drove me crazy the first time I encountered it: Is it possible the dates in your date table are dates but the dates in your ledger table are datetime? If so, you’ll need to convertthe datetime field to a date. If you need to preserve the time values in your ledger, make a copy of the datetime field, set that column’s type to date and join that field to your date table.
——————————
Christopher Schnaars
Laboratory Testing Inc.
Hatfield, Pennsylvania
——————————
——————————————- -
Eric Rosen
MemberApril 30, 2020 at 8:15 AM
Chris:Ā
Good idea…tried that a few weeks ago, with no luck.——————————
Eric Rosen
IT Manager
——————————
——————————————- -
Eric Rosen
MemberApril 30, 2020 at 8:19 AM
Audrey,Ā
Sample PBIX attached.Ā Ā
The DAX is straightforward:Ā Ā Ā Total Amount=Sumx(GLTable[Amount])
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā and then Total Amount Last Year = CALCULATE ([Total Amount],sameperiodlastyear(DateTable[Date])Ā Ā Ā
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā orĀ Ā Total Amount Last Year = CALCULATE ([Total Amount],dateadd(DateTable[Date],-1,Year)Ā Ā ĀNeither formula works.Ā Ā totally baffled.
——————————
Eric Rosen
IT Manager
——————————
——————————————- -
Audrey Abbey
MemberApril 30, 2020 at 10:00 AM
Hi Eric,ĀThanks for the sample.Ā
The issue is that your date table does not have continuous dates in it.Ā
All of the native time intelligence requires a date table with no gaps.ĀYou either need to handle your date intelligence manually, or you need to fill in the gaps on your time dimension.Ā
Here is Reza’s write up that I use to create date tables when I don’t have a data warehouse to connect to.
But you can also just create a list of dates in Excel and connect to it as a data source.Ā
https://radacad.com/all-in-one-script-to-create-date-dimension-in-power-bi-using-power-query——————————
Audrey Abbey
SR. BI Developer/Analyst
LeapFrogBI
Portland OR
——————————
——————————————- -
Eric,
Here you go.Ā I made the adjustments in your file.Ā There were a couple issues.Ā Ā
1. The relationship between GL table and Date table.Ā The fields were not the same data.Ā MM/YY to MM/DD/YY.
2. To fix this, I added a column to the GL table to add a full date MM/DD/YY (I just set everything to the first of the month)
3. On your reports, you should be using the year column from your date dimension table and not your GL fact table.I have attached the adjustments so you can see the changes I made.
——————————
Dan Edwards
Senior Manager
Crowe LLP
Huntington Beach CA
714-231-2202
dan.edwards@crowe.com
——————————
——————————————- -
Eric Rosen
MemberMay 1, 2020 at 8:09 AM
Dan,
Thank you for your help.Ā The date relationships (MM/YY vs MM/DD/YY) have been confusing, to say the least.Ā Appreciate your time.Ā
Eric——————————
Eric Rosen
IT Manager
——————————
——————————————-
DSC Communities replied 5 years, 11 months ago 1 Member · 0 Replies -
-
0 Replies
Sorry, there were no replies found.
The discussion ‘Time calculation errors — suggestions?’ is closed to new replies.