Forum Discussion

Nicpet0's avatar
Nicpet0
Frequent Visitor
3 months ago
Solved

DAX performance optimization

Dear community,   I am seeking help optimizing a Power BI report that is experiencing performance issues, which I suspect may be related to my DAX measure included below. The report is designed to ...
  • johnt75's avatar
    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.