SOLVED

GetPivotData and Time Values as Cell References

%3CLINGO-SUB%20id%3D%22lingo-sub-3034405%22%20slang%3D%22en-US%22%3EGetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3034405%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20seriously%20think%20that%20this%20is%20a%20bug.%20Actually%20maybe%20more%20than%20one%20bug.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirst%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20regular%20data%20model%2C%20if%20the%20source%20data%20includes%20a%20time%20value%20such%20as%2000%3A00%2C%20you%20can't%20display%20those%20fields%20as%20times.%2000%3A00%20appears%20as%2000%20and%20changing%20number%20format%20doesn't%20do%20anything.%20In%20addition%20to%20this%2C%20you%20can't%20make%20a%20cell%20reference%20to%20use%20getpivotdata%20using%20a%20time%20value%2C%20let's%20says%20my%20cell%20a3%20is%2000%3A00%20and%20I%20want%20to%20get%20that%20time's%20value%20but%20I%20can't%20reference%20it%20using%20a3.%20you%20have%20to%20hard%20code%20it%20as%20%220%22%20and%20this%20kills%20the%20purpose%20because%20you%20can't%20flashfill%20this%20way.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESecond%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20Excel's%20Data%20Model%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20get%20the%20pivot%20to%20display%20the%20time%20values%20correctly%20such%20as%2000%3A00.%20However%2C%20as%20you%20know%20using%20getpivotdata%20with%20Excel's%20Data%20Model%2C%20things%20get%20complicated%20and%20again%20you%20can't%20reference%20a%20cell%20as%20a%20time%20value%20because%20excel%20reads%20the%20time%20as%20%221899-12-30T00%3A00%3A00%22%20and%20referenced%20cell%20doesn't%20match%20this%20value.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20these%20really%20bugs%3F%20If%20so%20how%20can%20I%20report%20them%3F%20Is%20there%20anyway%20around%20this%3F%3C%2FP%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3034405%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3039515%22%20slang%3D%22en-US%22%3ERe%3A%20GetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3039515%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1142876%22%20target%3D%22_blank%22%3E%40kheldar%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3038947%22%20slang%3D%22en-US%22%3ERe%3A%20GetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3038947%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you!%20I%20managed%20to%20get%20it%20done%20by%20changing%20it%20to%20table%20name!%20You%20are%20super%20helpful.%20I%20can't%20thank%20you%20enough!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3035844%22%20slang%3D%22en-US%22%3ERe%3A%20GetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3035844%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1142876%22%20target%3D%22_blank%22%3E%40kheldar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt's%20hard%20to%20say%20without%20the%20file.%20What%20is%26nbsp%3B%3CSPAN%3EPivotTable1%2C%20is%20it%20generated%20automatically%20when%20you%20start%20typing%20%3CSTRONG%3E%22%5B%3C%2FSTRONG%3E%20%2C%20or%20you%20added%20it%20manually%3F%20In%20general%20it%20shall%20be%20name%20of%20the%20table%20which%20is%20source%20for%20PivotTable%2C%20not%20the%20name%20of%20the%20PivotTable.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3035374%22%20slang%3D%22en-US%22%3ERe%3A%20GetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3035374%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20the%20layout%3C%2FP%3E%3CP%3E%3DCUBEVALUE(%20%22ThisWorkbookDataModel%22%2C%3CBR%20%2F%3ECUBEMEMBER(%20%22ThisWorkbookDataModel%22%2C%20%22%5BPivotTable1%5D.%5BHour%20Formula%5D.%5B%22%26amp%3B%20TEXT(A3%2C%20%22hh%3Amm%22%20)%20%26amp%3B%20%22%5D%22)%2C%3CBR%20%2F%3ECUBEMEMBER(%22ThisWorkbookDataModel%22%2C%20%22%5BMeasures%5D.%5BSLA%5D%22)%20)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22kheldar_0-1639085432518.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F333035i271C218A18284492%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22kheldar_0-1639085432518.png%22%20alt%3D%22kheldar_0-1639085432518.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22kheldar_1-1639085461438.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F333036i64EF1B1E0E3CD0F0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22kheldar_1-1639085461438.png%22%20alt%3D%22kheldar_1-1639085461438.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22kheldar_2-1639085479739.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F333037iB9B8937D9E44AE94%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22kheldar_2-1639085479739.png%22%20alt%3D%22kheldar_2-1639085479739.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22kheldar_3-1639085498377.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F333038i1D9189488F120855%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22kheldar_3-1639085498377.png%22%20alt%3D%22kheldar_3-1639085498377.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhy%20do%20you%20think%20I%20still%20get%20%23N%2FA%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3035318%22%20slang%3D%22en-US%22%3ERe%3A%20GetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3035318%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1142876%22%20target%3D%22_blank%22%3E%40kheldar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20general%20yes%2C%20Power%20Pivot%20is%20only%20interface%20to%20data%20model.%20In%20this%20case%20to%20use%20implicit%20measures%20or%20create%20explicit%20measures%20by%20right%20click%20on%20table%20name%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20283px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F333006i3B8D76D21B8FD90A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20attached%20file%20same%20formula%20with%20implicit%20measure%2C%20it%20works.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3035269%22%20slang%3D%22en-US%22%3ERe%3A%20GetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3035269%22%20slang%3D%22en-US%22%3E%3CP%3EHmm%20I%20just%20learnt%20cube%20functions%20from%20your%20post%20and%20doing%20research%20on%20them.%20Can%20you%20use%20them%20without%20power%20pivot%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DCUBEVALUE(%20%22ThisWorkbookDataModel%22%2C%3CBR%20%2F%3ECUBEMEMBER(%20%22ThisWorkbookDataModel%22%2C%20%22%5BPivotTable4%5D.%5BHours%5D.%5B%22%26amp%3B%20TEXT(A3%2C%20%22hh%3Amm%22%20)%20%26amp%3B%20%22%5D%22)%2C%3CBR%20%2F%3ECUBEMEMBER(%22ThisWorkbookDataModel%22%2C%20%22%5BMeasures%5D.%5BSLA%5D%22)%20)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20formula%20returns%20%23N%2FA%20the%20pivot's%20name%20is%20PivotTable4%20the%20field%20to%20look%20for%20is%20Hours%20and%20the%20value%20is%20SLA.%20The%20pivot%20is%20in%20another%20sheet.%20What%20am%20i%20doing%20wrong%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3034805%22%20slang%3D%22en-US%22%3ERe%3A%20GetPivotData%20and%20Time%20Values%20as%20Cell%20References%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3034805%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1142876%22%20target%3D%22_blank%22%3E%40kheldar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'd%20avoid%20using%20of%20implicit%20measures%20and%20GETPIVOTDATA().%20For%20such%20sample%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20506px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F332853i144B7BB49F39DE93%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Ewe%20may%20create%20explicit%20measure%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3EValues%20sum%3A%3DSUM(%20%5BValue%5D%20)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eand%20return%20related%20value%20by%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DCUBEVALUE(%20%22ThisWorkbookDataModel%22%2C%0A%20%20%20%20%20%20%20CUBEMEMBER(%20%22ThisWorkbookDataModel%22%2C%20%22%5BTable1%5D.%5BTime%5D.%5B%22%20%26amp%3B%20TEXT(%20%24K%244%2C%20%22hh%3Amm%22%20)%20%26amp%3B%20%22%5D%22)%2C%0A%20%20%20%20%20%20%20CUBEMEMBER(%22ThisWorkbookDataModel%22%2C%20%22%5BMeasures%5D.%5BValues%20sum%5D%22)%20)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIn%20the%20sample%20above%20time%20is%20selected%20from%20drop%20down%20list%2C%20please%20see%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hello,

I seriously think that this is a bug. Actually maybe more than one bug.

 

First;

 

Using regular data model, if the source data includes a time value such as 00:00, you can't display those fields as times. 00:00 appears as 00 and changing number format doesn't do anything. In addition to this, you can't make a cell reference to use getpivotdata using a time value, let's says my cell a3 is 00:00 and I want to get that time's value but I can't reference it using a3. you have to hard code it as "0" and this kills the purpose because you can't flashfill this way.

 

Second;

 

Using Excel's Data Model,

 

You can get the pivot to display the time values correctly such as 00:00. However, as you know using getpivotdata with Excel's Data Model, things get complicated and again you can't reference a cell as a time value because excel reads the time as "1899-12-30T00:00:00" and referenced cell doesn't match this value.

 

Are these really bugs? If so how can I report them? Is there anyway around this?

7 Replies
best response confirmed by kheldar (Contributor)
Solution

@kheldar 

I'd avoid using of implicit measures and GETPIVOTDATA(). For such sample

image.png

we may create explicit measure

Values sum:=SUM( [Value] )

and return related value by

=CUBEVALUE( "ThisWorkbookDataModel",
       CUBEMEMBER( "ThisWorkbookDataModel", "[Table1].[Time].[" & TEXT( $K$4, "hh:mm" ) & "]"),
       CUBEMEMBER("ThisWorkbookDataModel", "[Measures].[Values sum]") )

In the sample above time is selected from drop down list, please see attached.

Hmm I just learnt cube functions from your post and doing research on them. Can you use them without power pivot?

 

 

=CUBEVALUE( "ThisWorkbookDataModel",
CUBEMEMBER( "ThisWorkbookDataModel", "[PivotTable4].[Hours].["& TEXT(A3, "hh:mm" ) & "]"),
CUBEMEMBER("ThisWorkbookDataModel", "[Measures].[SLA]") )

 

This formula returns #N/A the pivot's name is PivotTable4 the field to look for is Hours and the value is SLA. The pivot is in another sheet. What am i doing wrong?

@kheldar 

In general yes, Power Pivot is only interface to data model. In this case to use implicit measures or create explicit measures by right click on table name

image.png

In attached file same formula with implicit measure, it works.

@Sergei Baklan 

 

This is the layout

=CUBEVALUE( "ThisWorkbookDataModel",
CUBEMEMBER( "ThisWorkbookDataModel", "[PivotTable1].[Hour Formula].["& TEXT(A3, "hh:mm" ) & "]"),
CUBEMEMBER("ThisWorkbookDataModel", "[Measures].[SLA]") )

 

 

kheldar_0-1639085432518.png

 

kheldar_1-1639085461438.pngkheldar_2-1639085479739.png

kheldar_3-1639085498377.png

 

Why do you think I still get #N/A ?

@kheldar 

It's hard to say without the file. What is PivotTable1, is it generated automatically when you start typing "[ , or you added it manually? In general it shall be name of the table which is source for PivotTable, not the name of the PivotTable.

Thank you! I managed to get it done by changing it to table name! You are super helpful. I can't thank you enough!

@kheldar , you are welcome