Power Pivot CALCULATE vs. RELATEDTABLE

Redoute

New Member
Joined
Nov 4, 2018
Messages
12
I'm a beginner with Power Pivot/DAX, and got thinking about that:

Given two tables: items and groups, related by columns [groupid]. I create calculated columns in the groups table. There is more than one way to do it:
Code:
groups[n items 1]=COUNTROWS(RELATEDTABLE(items))
groups[max fact 1]=MAXX(RELATEDTABLE(items), items[somefact])

groups[n items 2]=CALCULATE(COUNTROWS(items))
groups[max fact 2]=CALCULATE(MAX(items[somefact]))
A third approach is defining measures in the items table, then use the measures in calculated columns:
Code:
items[n items]:=COUNTROWS()
groups[n items 3]=[n items]
items[max fact]:=MAX(items[somefact])
groups[max fact 3]=[max fact]
Assuming my tables will be large at some time, are there pros and cons?
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Thanks for your advice.

I think your rules #1 (results will be counted in a pivot table) and #3 (low cardinality) may apply. However I will probably enhance the underlying PostgreSQL query instead of using DAX calculated columns.

I made an Excel file for playing with one kind of report I want to create. Took me a lot of try and error to create measures that seem to work. If interested please download and review https://forplan-my.sharepoint.de/:x...lGtf8cQlT08GwBRfP8s8U6ezX56P-ZKwb6tQ?e=mVNVhG.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top