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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NorthernGuy
Frequent Visitor

Trailing 12 week cash balance line graph

Hi,

 

I am accessing QuickBooks Online using the content pack and look to create a WEEKLY, trailing 12 week line graph representing the actual cash balance for each week ( 13 data points -- cash balance on the day of the report and then the cash balance for each of 12 weeks prior (todays date minus 7 days, 14 days, etc).  (Once/if I get this working, I will look to add bar chart with total cash deposits and total cash payments for that same 7 day period).  

 

What I attempted to do was use the Measures below to calculate the cash balance, this formula worked, but obviously, I can put these Measures into a line chart.  I included a Visual Filter on the specific Cash Account that is the subject of the graph.

 

 

T0W Cash = SUM(GeneralLedger[TxnAmount]

T1W Cash = CALCULATE(SUM(GeneralLedger[TxnAmount]), 'GeneralLedger'[Date] <= TODAY()-7)

T2W Cash = CALCULATE(SUM(GeneralLedger[TxnAmount]), 'GeneralLedger'[Date] <= TODAY()-14)

 

Day of the Report --> T0W

Trailing 1 Week --> T1W

Etc.

 

Suggestions?

 

1 ACCEPTED SOLUTION

I suggest you try to use the calendar table. Create a calculated column that creates a simple flag "last 13 weeks". Each week either is or isn't in the last 13. Then add a slicer (or filter ) and select "last 13 weeks". This will filter your calendar table. Then add a week column from the calendar table to your X axis, and write a single measure that does the calc.  This way you leverage the natural filtering behaviour to get what you need. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

5 REPLIES 5
samdthompson
Memorable Member
Memorable Member

Hi, @MattAllington is quite right. If you dont have a date table handy, here is a quick formula based one. Go to ribbon >> Modelling >> New Table

 

DateTable = ADDCOLUMNS (CALENDAR ( "01/01/2015","31/12/2017"),"Year", YEAR ( [Date] ),"Monthnumber", FORMAT ( [Date], "MM" ),"YearMonthShort", FORMAT ( [Date], "YYYY/MMM" ),"MonthNameLong", FORMAT ( [Date], "mmmm" ),"DayOfWeekNumber", WEEKDAY ( [Date] ),"DayOfWeek", FORMAT ( [Date], "dddd" ),"Quarter", "Q" & FORMAT ( [Date], "Q" ))

// if this is a solution please mark as such. Kudos always appreciated.

It's not clear to me what you are after. Do you want a rolling 12 week average, or do you want to see the last 12 weeks actual on a chart?  Or both?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi Matt,

 

Thanks for responding....

 

I want 13 data points, or amounts, representing the actual cash balance for the current day (the day the "user" generates the graph) and then the prior 12 weeks (7/14/21/etc days prior) which I can then chart on a line graph.  I'd like to chart these data points on a line graph with the X axis as the dates and then the Y axis as the amounts.

 

I think I understand how to calculate the data points, I just don't know how to associated them to a date on the X axis -- as a Measure is not associated to a date.

 

 

 

 

I suggest you try to use the calendar table. Create a calculated column that creates a simple flag "last 13 weeks". Each week either is or isn't in the last 13. Then add a slicer (or filter ) and select "last 13 weeks". This will filter your calendar table. Then add a week column from the calendar table to your X axis, and write a single measure that does the calc.  This way you leverage the natural filtering behaviour to get what you need. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi Matt (and Sam),

 

Thank you!  This works.  Once you see it, it's so much easier.

 

Appreciate the help.

 

Best.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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