Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Need Help With Dax Table Query

I have the below Dax measure that produces a list of parent suppliers with the sum of the spend on them from a fact table.   Parent Supl Spend = var parents = SUMMARIZE('Export','Export'[ParentSup...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    I suggest you to try this measure.

     

    GROUP =
    CALCULATE (
        MAX ( 'Parent Supl Spend'[Spend] ),
        ALLEXCEPT ( 'Parent Supl Spend', 'Parent Supl Spend'[ParentSupplierName] )
    )

     

     

    If you want to get max spend for each user in calcualted table, please try this code.

    Parent Supl Spend =
    VAR _Parent =
        SUMMARIZE (
            'Export',
            'Export'[ParentSupplierName],
            'Export'[LeaderName],
            "Spend", SUM ( 'Export'[Spend Amount] )
        )
    VAR _MAX =
        SUMMARIZE (
            FILTER (
                _Parent,
                VAR _MaxSpend =
                    MAXX (
                        FILTER ( _Parent, [ParentSupplierName] = EARLIER ( [ParentSupplierName] ) ),
                        [Spend]
                    )
                RETURN
                    [Spend] = _MaxSpend
            ),
            [ParentSupplierName],
            [LeaderName],
            [Spend]
        )
    RETURN
        _MAX

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.