TM1 Tools Issues And Discussions (Was *KEY_ERR Tracer)

User avatar
Martin Ryan
Site Admin
Posts: 1988
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

TM1 Tools Issues And Discussions (Was *KEY_ERR Tracer)

Post by Martin Ryan »

I've posted this before, but wanted to add it to this thread.

It's a piece of VBA code that tells you where a DBRW formula in Excel is picking up data from in a cube. If there is a *KEY_ERR then it will highlight what is wrong with your formula. Useful if you've got complex reports and also can be useful for building DBRW formulae by hand.

If someone makes any enhancements, please post back. I'd like to see an alias function added.

The usual disclaimers apply... no warranties and not responsible for what the code does to your TM1 server, Excel or anything else.

Martin

(Admin Note: Subject line modified since this thread now relates to all of TM1 Tools, not just ther tracer)
Attachments
TM1Tracer.zip
(20.68 KiB) Downloaded 619 times
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
User avatar
Martin Ryan
Site Admin
Posts: 1988
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: *KEY_ERR Tracer

Post by Martin Ryan »

New version that includes a tool that zips through and makes all worksheets values only, removing any TM1 formulae - useful for quickly emailing a file off to a non-TM1 user.

Could be further revised to only get rid of TM1 formula, instead of ALL formula, the methodology is in this forum somewhere if someone wants to dig it out and apply it.

Martin
Attachments
TM1Tracer.zip
(23.65 KiB) Downloaded 420 times
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Wim Gielis
MVP
Posts: 3118
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: *KEY_ERR Tracer

Post by Wim Gielis »

Regarding makeAllSheetsValues() and Sub pasteSheetAsValues(), see also: http://www.rondebruin.nl/values.htm (and other pages on his website).

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: *KEY_ERR Tracer

Post by Steve Rowe »

Version 0.2a

Added a new sub to clear only TM1 formula from all sheets in the workbook.
If anyone else wants to add useful TM1 type utilities to the tool bar feel free to add to the code, would be nice to have our own little toolbar.
Something that needs doing is to add the script that puts the tool bar somewhere nicer that I saw someone had posted

Usual disclaimers apply,

Detailed Changelog

Code: Select all

Sub ChangeLog()

''''Version 0.1 Martin Ryan - Original version


''''Version 0.2 Steve Rowe - Minor bug fixes and added TM1 Only clear macro - 17/04/09
'Added option explicit and defined a variable (Sheet)
'Added code to solve issue around selection of hidden worksheets.
'Added event enabling and disabling
'Added black list macro
'Added version number


End Sub
--Edit Added the file, missed the fact that the xla was refused and had to zip it :oops:
Attachments
TM1Tracer v0.2.xla.zip
OLAP Forums TM1 Toolbar v 0.2a
(27.33 KiB) Downloaded 364 times
Technical Director
www.infocat.co.uk
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: *KEY_ERR Tracer

Post by Steve Rowe »

Small update as I had not changed the tool bar to reference the new macro, so both icons were running the same macro, doh! Thanks to Martin for pointing this out!
Attachments
TM1Tracer v0.3.xla.zip
(26.74 KiB) Downloaded 380 times
Technical Director
www.infocat.co.uk
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: *KEY_ERR Tracer

Post by Steve Rowe »

Sorry all further fix in the TM1 only macro that allows for formula with no opening bracket "(" that was causing the macro to fail. (Like = server &"Management Information") :oops:
Attachments
TM1Tracer v0.4.xla.zip
(30.99 KiB) Downloaded 424 times
Technical Director
www.infocat.co.uk
User avatar
Martin Ryan
Site Admin
Posts: 1988
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: *KEY_ERR Tracer

Post by Martin Ryan »

Latest version now includes ability to trace DBRA, DBSA and VIEW formula. I've also cleaned up the toolbar build, based on Alan's suggestions in the General forum.

For the sake of simplicity I've removed the button for the Values Only macro, and left only the remove TM1 formula, which doesn't remove Excel formula. If you want to give yourself and users the option of both you'll just need to uncomment the button addition in the BuildToolbar sub. I don't think my users could handle the nuance between the two, so have kept it simple by keeping the old one out.

As an added bonus I've also put in some documentation on how it works, including some screenshots.

Any problems, full refunds are available. :lol:

Martin
Attachments
TM1Tools.zip
(155.05 KiB) Downloaded 512 times
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: *KEY_ERR Tracer

Post by Steve Rowe »

Next change required should anyone choose to take up the challenge. Method to close the formula trace easily so that you can avoid having to move the mouse to click on the cross to close the dialog.

Maybe something on the mouse move event or something...

Also the aproach at the moment doesn't work for more complex TM1 formula like
=IF(NOT(DBRA("traxx:management information",TRIM(LEFT(A28,100)),$C$19)=$B$14),DBRA("traxx:management information",TRIM(LEFT(A28,100)),$C$19),DBRA("traxx:management information",TRIM(LEFT(A28,100))&DBRA("traxx:Sub-analysis 1",E28,$C$19)&" N",$C$19))
Technical Director
www.infocat.co.uk
Wim Gielis
MVP
Posts: 3118
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: *KEY_ERR Tracer

Post by Wim Gielis »

This is somewhat better code with respect to makeAllSheetsValues and pasteSheetAsValues:

Code: Select all

Sub makeAllSheetsValues()
' This code saves the active workbook with a new name, then
' cycles through the sheets in the worbook and pastes them as values
' removing all formula
    Dim saveAsName As String, thisSheet As String, Sheet As Worksheet, SheetVisible As XlSheetVisibility
    saveAsName = ActiveWorkbook.FullName
    saveAsName = Left(saveAsName, Len(saveAsName) - 4) & "valuesOnly.xls"
    saveAsName = Application.GetSaveAsFilename(saveAsName)

    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
        .EnableEvents = False
        .Calculation = xlCalculationManual
    End With

    If saveAsName = "False" Or saveAsName = "" Then Exit Sub
    ActiveWorkbook.SaveAs saveAsName
    
    For Each Sheet In ActiveWorkbook.Worksheets
        'collect the visible status of the worksheet
        SheetVisible = Sheet.Visible
        'unhide the sheet
        Sheet.Visible = xlSheetVisible
        'Sheets(Sheet.Name).Select
        pasteSheetAsValues Sheet
        'set the visible status back to what it was before
        Sheet.Visible = SheetVisible
    Next Sheet

    With Application
        .ScreenUpdating = True
        .DisplayAlerts = True
        .EnableEvents = True
        .Calculation = xlCalculationAutomatic
    End With
    
    ActiveWorkbook.Save
    MsgBox "Workbook has been saved as values only copy", vbInformation
End Sub

Sub pasteSheetAsValues(sh As Worksheet)

    With ActiveSheet.UsedRange
        .Value = .Value
    End With

End Sub
Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
MVP
Posts: 3118
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: *KEY_ERR Tracer

Post by Wim Gielis »

Regarding the line of code:

For Each sheet In ActiveWorkbook.Sheets

Watch out for Chart sheets. The code will hang in case a Chart sheet is encountered. Use:

For Each sheet In ActiveWorkbook.Worksheets
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: *KEY_ERR Tracer

Post by Steve Vincent »

i like that. would be even better if it only changed TM1 specific formulas, but its a good place to start :)
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: *KEY_ERR Tracer

Post by Steve Vincent »

Wim Gielis wrote:Regarding the line of code:

For Each sheet In ActiveWorkbook.Sheets

Watch out for Chart sheets. The code will hang in case a Chart sheet is encountered. Use:

For Each sheet In ActiveWorkbook.Worksheets
Can't get it to work, it fails to compile on the line highlighted;
For Each Sheet In ActiveWorkbook.Worksheets
'collect the visible status of the worksheet
SheetVisible = Sheet.Visible
'unhide the sheet
Sheet.Visible = xlSheetVisible
'Sheets(Sheet.Name).Select
pasteSheetAsValues Sheet
'set the visible status back to what it was before
Sheet.Visible = SheetVisible
Next Sheet
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: *KEY_ERR Tracer

Post by Steve Rowe »

Did you copy the other sub in?

Sub pasteSheetAsValues(sh As Worksheet)

With ActiveSheet.UsedRange
.Value = .Value
End With

End Sub

Might need to change the highlighted line to

Call pasteSheetAsValues (Sheet)

Otherwise nor sure, over to Wim
Technical Director
www.infocat.co.uk
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: *KEY_ERR Tracer

Post by Steve Vincent »

Steve Rowe wrote:Did you copy the other sub in?

Sub pasteSheetAsValues(sh As Worksheet)

With ActiveSheet.UsedRange
.Value = .Value
End With

End Sub

Might need to change the highlighted line to

Call pasteSheetAsValues (Sheet)

Otherwise nor sure, over to Wim
Ah. I had to edit that sub because it refuses to run on its own - i wanted the option of valuing either a single sheet OR a full book. Guess that code only works doing the full book, which is a shame ;)
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
dubs
Posts: 131
Joined: Fri May 22, 2009 10:43 am
Version: 9.4
Excel Version: 2003

Re: *KEY_ERR Tracer

Post by dubs »

i cant get this to work, it shows all red rows and nothing in cols 1 & 3 for all rows even though the formula works and recalculates ok.

any ideas?
Wim Gielis
MVP
Posts: 3118
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: *KEY_ERR Tracer

Post by Wim Gielis »

Hi all

1/

Code: Select all

Sub pasteSheetAsValues(sh As Worksheet)

With ActiveSheet.UsedRange
.Value = .Value
End With

End Sub
My bad, sh is an argument in this sub. But I forgot to use it in the line

Code: Select all

With ActiveSheet.UsedRange
that should read:

Code: Select all

With sh.UsedRange
2/

Code: Select all

Call pasteSheetAsValues (Sheet)
does exactly the same as:

Code: Select all

pasteSheetAsValues Sheet
. As said above, the code of pasteSheetAsValues should be in the code. The sub does not run on its own since there is an argument that should be passed to it (a variable declared as Worksheet for instance)

3/

Regarding the whole workbook or 1 sheet:

For 1 sheet it would be something along the lines of:

Code: Select all

Set Sheet = ActiveSheet
'collect the visible status of the worksheet
SheetVisible = Sheet.Visible
'unhide the sheet
Sheet.Visible = xlSheetVisible
'Sheets(Sheet.Name).Select
pasteSheetAsValues Sheet
'set the visible status back to what it was before
Sheet.Visible = SheetVisible
Hence, no loop.

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
MVP
Posts: 3118
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: *KEY_ERR Tracer

Post by Wim Gielis »

dubs

Perhaps you can add a few small screenshots to your post (or a new post)? (without sensitive information of course).

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
dubs
Posts: 131
Joined: Fri May 22, 2009 10:43 am
Version: 9.4
Excel Version: 2003

Re: *KEY_ERR Tracer

Post by dubs »

Cheers Wim,

yes may help? :)

it is is strange because if i do an alt+f9 then it all calculates correctly so the calculations work
Attachments
errorxla.jpg
errorxla.jpg (63.02 KiB) Viewed 14479 times
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: *KEY_ERR Tracer

Post by Steve Vincent »

Cheers Wim :)

For others, the full sub that you can add as a menu item / button etc to value just the current sheet is;

Code: Select all

Sub pasteSingleSheetAsValues()
Dim Sheet As Worksheet, SheetVisible As XlSheetVisibility

Set Sheet = ActiveSheet
'collect the visible status of the worksheet
SheetVisible = Sheet.Visible
'unhide the sheet
Sheet.Visible = xlSheetVisible
'Sheets(Sheet.Name).Select
pasteSheetAsValues Sheet
'set the visible status back to what it was before
Sheet.Visible = SheetVisible

End Sub
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: *KEY_ERR Tracer

Post by Steve Vincent »

dubs wrote:Cheers Wim,

yes may help? :)

it is is strange because if i do an alt+f9 then it all calculates correctly so the calculations work
dubs, which addin did you try? i just grabbed the latest from Steve and it's fine. The tracer is missing all the TM1 bits of info, so are you logged in (stock question i ask everyone!) and do you have the admin license rights? Excel can sometimes loose the link to TM1 even if the server explorer looks fine so might be worth closing excel and trying again as a start :)
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
Post Reply