Forum Discussion
DAX performance optimization
- 3 months ago
The first thing I would try is to incorporate the sharepoint files into the main semantic model. The performance of a model in import mode is always going to be better than a composite model running partly in DQ. If you don't control the main semantic model yourself, have a word with whoever does and see if they can include the sharepoint files for you. You could even give them TMDL files to create the tables and relationships, set display properties etc.
If including the sharepoint files in the main model isn't possible then there are a couple of things I can think to try, but I don't know whether they will have a significant impact on performance. Firstly, rather than specifying ranges of values for 'G L Account Category SharePoint'[Index] try specifying actual values - so rather than > 7 and <= 10, specify { 8, 9, 10 } with the IN operator.
Secondly, you could try and create the filter for 'G L Account' manually rather than relying on the limited relationship. If there was a Key column in both 'G L Account' and 'G L Account Sharepoint' you could try something like
ACT = VAR _Category = SELECTEDVALUE ( 'G L Account Category SharePoint'[G L Account Category] ) VAR _IsDetailLevel = ISINSCOPE ( 'G L Account SharePoint'[G L Account Subcategories] ) || ISINSCOPE ( 'G L Account SharePoint'[G L Account] ) VAR GrossProfitFilter = TREATAS ( CALCULATETABLE ( VALUES ( 'G L Account Sharepoint'[Key] ), 'G L Account Category SharePoint'[Index] IN { 0, 1, 2 } ), 'G L Account'[Key] ) VAR TotalOverheadsFilter = TREATAS ( CALCULATETABLE ( VALUES ( 'G L Account Sharepoint'[Key] ), 'G L Account Category SharePoint'[Index] IN { 4, 5, 6 } ), 'G L Account'[Key] ) RETURN IF ( _IsDetailLevel, - [Amount], SWITCH ( _Category, "Gross Profit", CALCULATE ( - [Amount], REMOVEFILTERS ( 'G L Account Category SharePoint' ), GrossProfitFilter ), "Total Overheads", CALCULATE ( - [Amount], REMOVEFILTERS ( 'G L Account Category SharePoint' ), TotalOverheadsFilter ) ) )It might also be worth examining the [Amount] measure to see if there are performance tweaks you could make in there.
Hello Nicpet0
There are multiple area where we can imporve perfromance.
try this measure
ACT =
VAR _IsDetailLevel =
ISINSCOPE ( 'G L Account SharePoint'[G L Account Subcategories] )
|| ISINSCOPE ( 'G L Account SharePoint'[G L Account] )
VAR _BaseAmount = -[Amount]
RETURN
IF (
_IsDetailLevel,
_BaseAmount,
VAR _Category = SELECTEDVALUE ( 'G L Account Category SharePoint'[G L Account Category] )
RETURN
SWITCH (
_Category,
"Gross Profit",
CALCULATE (
-[Amount],
KEEPFILTERS (
FILTER (
ALL ( 'G L Account Category SharePoint' ),
'G L Account Category SharePoint'[Index] < 3
)
)
),
"Total Overheads",
CALCULATE (
-[Amount],
KEEPFILTERS (
FILTER (
ALL ( 'G L Account Category SharePoint' ),
'G L Account Category SharePoint'[Index] > 3
&& 'G L Account Category SharePoint'[Index] < 7
)
)
),
"Total Personnel Costs",
CALCULATE (
-[Amount],
KEEPFILTERS (
FILTER (
ALL ( 'G L Account Category SharePoint' ),
'G L Account Category SharePoint'[Index] > 7
&& 'G L Account Category SharePoint'[Index] < 10
)
)
),
"EBITDA",
CALCULATE (
-[Amount],
KEEPFILTERS (
FILTER (
ALL ( 'G L Account Category SharePoint' ),
'G L Account Category SharePoint'[Index] < 13
)
)
),
"EBIT",
CALCULATE (
-[Amount],
KEEPFILTERS (
FILTER (
ALL ( 'G L Account Category SharePoint' ),
'G L Account Category SharePoint'[Index] < 15
)
)
),
_BaseAmount
)
)
If my response helped you, please consider clicking
Accept as Solution ✅ and giving it a Like 👍 – it helps others in the community too.
Thanks,
Connect with me on:
LinkedIn |
Data With Pankaj - YouTube
pankajnamekar25
Thanks for the response! Can you explain to me how this new measure is better than my current?
Thanks.
- pankajnamekar253 months agoSuper User
Hello Nicpet0
If my response helped you, please consider clicking
Accept as Solution ✅ and giving it a Like 👍 – it helps others in the community too.
Thanks,
Connect with me on:
LinkedIn |
Data With Pankaj - YouTube- Nicpet03 months agoFrequent Visitor
pankajnamekar25
Firstly, the code you send did not work. Secondly, i am 99% sure your responses comes from ChatGPT. In your latest post, some of the explanations does not make sense at all.For example this - Typo fixed in Total Personnel Costs branch (ShareSheet → SharePoint) - There is no typo at all in the code. Sorry this was not helpful