Pro Tip: You can lookup TEXT values from Data Model using CUBEVALUE (No Pivot Tables needed)
Our take
Hi everyone,
I've been working on optimizing some heavy Excel dashboards recently. I wanted to get away from VLOOKUPs and hidden Pivot Tables because the file was getting too slow and crashing with >1M rows.
I switched to using CUBE functions to pull data directly from the Data Model into a custom layout. It works great for numbers, but I hit a wall when trying to pull **text values** (like a "Salesperson Name" based on an Order ID). Standard CUBE functions usually return numbers or error out with text.
I figured out a workaround using a specific DAX measure logic and wanted to share it with the community.
**The Solution:*\*
Instead of just referencing the column directly, you need to create a Measure in Power Pivot that forces a text return.
**Scenario A: Lookup within the same table*\*
If you just need a text value from the row you are filtering:
MeasureName := FIRSTNONBLANK('Table'[Column], 1)
**Scenario B: Lookup from a related table (The "Filter Propagation" fix)*\*
If you are filtering by Orders but want to see the Salesperson from a related 'People' table, standard filters won't flow "uphill". You need to force it:
MeasureName := CALCULATE(FIRSTNONBLANK('People'[Salesperson], 1), 'Orders')
**The Excel Formula:*\*
Then, you can call this measure inside Excel using CUBEVALUE. It will look something like this:
=CUBEVALUE("ThisWorkbookDataModel", "[Measures].[MeasureName]", "[Orders].[ID].&[" & A2 & "]")
This returns the text string dynamically based on your cell value (A2). It made my dashboard significantly faster and cleaner.
**Video Guide:*\*
I recorded a short tutorial explaining the logic and showing the setup step-by-step if you want to see it in action:
https://youtu.be/D2fCKXoGVb0
Hope this helps anyone stuck with rigid Pivot Tables!
[link] [comments]
Read on the original site
Open the publisher's page for the full experience
Related Articles
- Power Query + Power Pivot + DAX = fast and powerfulI inherited a monthly Update that is mostly the same data updated and then some analysis. I paste the raw data from 9 different places, manually aligning them as a single table. There are a load of pivots that have calculated fields and items and updating them take a morning and most of that was just waiting for the calculated items in the pivots to refresh. While I was waiting for that to refresh, I decided to see if I could recreate the same pivots in a new sheet, using powerquery. In the time it took for my original sheet to refresh, I loaded the data into powerquery, aligned the data, loaded everything into the model, created custom lists for the columns to look up off to allow for differences in the names between data sources, created extra lookups to improve the filtering, created the relationships, created DAX functions to replace the in-pivot calculated items and fields and recreated the tables and charts I use every month. The original refresh finshed about 5 minutes after I did all that. I did a test refresh and what took a morning now takes about 3 minutes on my new sheet. I'm a fairly recent convert to PQE, but this little project is the first time I've really dug into Power Pivot. It could be a game changer for a lot of my work. There's stuff I was doing in PQE that is a lot easier to do in PowerPivot. Being able to link lookup tables, data tables and facts together is really fun. submitted by /u/Thisoneissfwihope [link] [comments]
- Stop using ungodly INDEX math to flatten 2D schedules. TOCOL() + FILTER() is all you need.This comes up constantly. Someone gets handed a resource tracker or a system export where tasks are split across "Morning Task" and "Afternoon Task" columns, and they need a flat list to dump into a Pivot Table. Simple enough ask. The fun part? Half these exports don't even leave cells blank - they write out [empty] as literal text, so any trick that relies on detecting blank cells just falls flat. And on top of that there's usually a Status column you need to drag along, but only once per person - not stamped next to every single task row like a broken rubber stamp. Old solution was some deeply cursed nested INDEX/ROW formula that nobody could read six months later. If you're still doing that, please stop. On Office 365 you can handle the whole thing in one shot: =LET(data, A2:C11, status, D2:D11, col_data, TOCOL(data), col_status, TOCOL(IF(SEQUENCE(1,COLUMNS(data))=1, status, "")), FILTER(HSTACK(col_data, col_status), col_data<>"[empty]")) TOCOL flattens the grid, the IF/SEQUENCE combo makes sure the status only shows up next to the name and not repeated under every task, HSTACK glues the two columns together, and FILTER kills all the [empty] noise. Keep your ranges the same size throughout or you'll get a #VALUE! staring back at you. These dynamic array functions honestly flew under the radar for a lot of people who don't spend their weekends reading Excel update logs. Hope it saves someone a headache. Note; for Excel 2019 and 2021 you can use power query. However in the 2021 version you can use the filter and sequence function. In 2021 version; the formulas are; =FILTER(INDEX(A2:C11,MOD(SEQUENCE(30)-1,10)+1,INT((SEQUENCE(30)-1)/10)+1),INDEX(A2:C11,MOD(SEQUENCE(30)-1,10)+1,INT((SEQUENCE(30)-1)/10)+1)<>"[empty]") and =FILTER(IF(INT((SEQUENCE(30)-1)/10)+1=1,INDEX(D2:D11,MOD(SEQUENCE(30)-1,10)+1),""),INDEX(A2:C11,MOD(SEQUENCE(30)-1,10)+1,INT((SEQUENCE(30)-1)/10)+1)<>"[empty]") one thank go at user for pointing it out to me Excel_User_1977 submitted by /u/Good-Willingness2234 [link] [comments]