Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ARWCL
Regular Visitor

DAX syntax error for ...

i have asked Power Bi to create a DAX function to show me an individuals wealth based on slicers for individual, and month end dates but when i have copied this in to Power BI Desktop I keep getting error messages saying 'The syntax for '???' is incorrect. The ??? has been [Date], [Value] etc. and i have seemed to correct these but it is not saying 'The syntax for ',' is incorrect'. I have no idea what is causing this or how to correct. Can anyone help? I know it is long but the measure is below:

 

Individual Wealth =
VAR SelectedMember = SELECTEDVALUE(FamilyMembers[MemberName])

-- Capture the selected date from the date slicer
-- If no date is selected, use the latest date in the Value table
VAR SelectedDate =
    IF(
        ISBLANK(SELECTEDVALUE(DateTable[Date])),
        CALCULATE(MAX('Value'[Date])),  -- Get the latest available date from the Value table
        SELECTEDVALUE(DateTable[Date])
    )

-- Calculate the most recent value for each asset owned by the selected family member up to the selected date
VAR MemberAssetValues =
    SUMX(
        FILTER(
            FamilyMembers,
            FamilyMembers[MemberName] = SelectedMember &&
            FamilyMembers[OwnershipStartDate] <= SelectedDate &&
            (FamilyMembers[OwnershipEndDate] >= SelectedDate || ISBLANK(FamilyMembers[OwnershipEndDate]))
        ),
        VAR CurrentAssetID = FamilyMembers[AssetID]
        VAR AssetValue =
            CALCULATE(
                MAX('Value'[Value]),
                'Value'[AssetID] = CurrentAssetID,
                'Value'[Date] <= SelectedDate  -- Consider the most recent value prior to or equal to the selected date
            )
       
        -- Handle the ownership of other assets, e.g., AssetID 1 owns AssetID 3
        VAR SubAssetValue =
            SUMX(
                FILTER(
                    Value,
                    Value[ParentAssetID] = CurrentAssetID &&
                    Value[Date] <= SelectedDate
                ),
                Value[Value] *
                LOOKUPVALUE(
                    FamilyMembers[OwnershipPercentage],
                    FamilyMembers[AssetID], Value[ParentAssetID],
                    FamilyMembers[MemberName], SelectedMember
                )
            )

        -- Calculate the total value for the current asset including its ownership of other assets
        RETURN
            (AssetValue + SubAssetValue) * FamilyMembers[OwnershipPercentage]
    )

-- Case when no individual is selected, calculate the total wealth for all family members
VAR TotalWealthAllMembers =
    SUMX(
        FILTER(
            FamilyMembers,
            FamilyMembers[OwnershipStartDate] <= SelectedDate &&
            (FamilyMembers[OwnershipEndDate] >= SelectedDate || ISBLANK(FamilyMembers[OwnershipEndDate]))
        ),
        VAR CurrentAssetID = FamilyMembers[AssetID]
        VAR AssetValue =
            CALCULATE(
                MAX(Value[Value]),
                Value[AssetID] = CurrentAssetID,
                Value[Date] <= SelectedDate
            )
       
        -- Handle sub-assets owned by this asset (e.g., AssetID 1 owning AssetID 3)
        VAR SubAssetValue =
            SUMX(
                FILTER(
                    Value,
                    Value[ParentAssetID] = CurrentAssetID &&
                    Value[Date] <= SelectedDate
                ),
                Value[Value] *
                LOOKUPVALUE(
                    FamilyMembers[OwnershipPercentage],
                    FamilyMembers[AssetID], Value[ParentAssetID]
                )
            )

        -- Calculate total value of the asset including sub-assets
        RETURN
            (AssetValue + SubAssetValue) * FamilyMembers[OwnershipPercentage]
    )

-- Final calculation: if a member is selected, calculate their wealth; if not, show the total wealth
RETURN
IF(
    ISBLANK(SelectedMember),
    TotalWealthAllMembers,  -- No selection, show total wealth
    MemberAssetValues  -- Member selected, show individual wealth based on the date
)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ARWCL 

Based on your data and the final goal, i create the following measures.

Note:there are no relationships among tables.

 

MEASURE =
VAR filterdate =
    IF (
        ISFILTERED ( DateTable[Date] ),
        MAX ( DateTable[Date] ),
        MAXX ( ALLSELECTED ( 'Value'[Date] ), [Date] )
    )
VAR filterassetid =
    CALCULATETABLE (
        VALUES ( 'FamilyMembers'[AssetID] ),
        FamilyMembers[OwnershipStartDate] <= filterdate,
        OR (
            FamilyMembers[OwnerShipEndDate] >= filterdate,
            ISBLANK ( FamilyMembers[OwnerShipEndDate] )
        )
    )
VAR maxdate =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Value' ),
            [AssetID]
                IN filterassetid
                    && [AssetID]
                        IN VALUES ( 'Value'[AssetID] )
                            && [Date] <= filterdate
        ),
        [Date]
    )
VAR maxvalue =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Value' ),
            [Date] = maxdate
                && [AssetID]
                    IN VALUES ( 'Value'[AssetID] )
                        && [AssetID] IN filterassetid
        ),
        [Value]
    )
VAR subvalue =
    SUMX (
        FILTER (
            ALLSELECTED ( 'Value' ),
            [ParentAssetID]
                IN VALUES ( 'Value'[AssetID] )
                    && [ParentAssetID]
                    IN filterassetid
                        && [Date] <= filterdate
        ),
        [Value]
    )
VAR ownerper =
    MAXX (
        FILTER (
            ALLSELECTED ( FamilyMembers ),
            [AssetID]
                IN VALUES ( FamilyMembers[AssetID] )
                    && [AssetID]
                        IN VALUES ( 'Value'[AssetID] )
                            && [AssetID] IN filterassetid
        ),
        [OwnershipPercentage]
    )
RETURN
    ( maxvalue + subvalue * ownerper ) * ownerper
Measure2 =
VAR a =
    ADDCOLUMNS (
        SUMMARIZE ( ALLSELECTED ( 'Value' ), [AssetID] ),
        "Measure", [Measure]
    )
RETURN
    SUMX ( FILTER ( a, [AssetID] IN VALUES ( 'Value'[AssetID] ) ), [Measure] )

 

Then put the measure2 to the card.

Output

vxinruzhumsft_0-1727078154779.png

Best Regards!

Yolo Zhu

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

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @ARWCL 

Based on your data and the final goal, i create the following measures.

Note:there are no relationships among tables.

 

MEASURE =
VAR filterdate =
    IF (
        ISFILTERED ( DateTable[Date] ),
        MAX ( DateTable[Date] ),
        MAXX ( ALLSELECTED ( 'Value'[Date] ), [Date] )
    )
VAR filterassetid =
    CALCULATETABLE (
        VALUES ( 'FamilyMembers'[AssetID] ),
        FamilyMembers[OwnershipStartDate] <= filterdate,
        OR (
            FamilyMembers[OwnerShipEndDate] >= filterdate,
            ISBLANK ( FamilyMembers[OwnerShipEndDate] )
        )
    )
VAR maxdate =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Value' ),
            [AssetID]
                IN filterassetid
                    && [AssetID]
                        IN VALUES ( 'Value'[AssetID] )
                            && [Date] <= filterdate
        ),
        [Date]
    )
VAR maxvalue =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Value' ),
            [Date] = maxdate
                && [AssetID]
                    IN VALUES ( 'Value'[AssetID] )
                        && [AssetID] IN filterassetid
        ),
        [Value]
    )
VAR subvalue =
    SUMX (
        FILTER (
            ALLSELECTED ( 'Value' ),
            [ParentAssetID]
                IN VALUES ( 'Value'[AssetID] )
                    && [ParentAssetID]
                    IN filterassetid
                        && [Date] <= filterdate
        ),
        [Value]
    )
VAR ownerper =
    MAXX (
        FILTER (
            ALLSELECTED ( FamilyMembers ),
            [AssetID]
                IN VALUES ( FamilyMembers[AssetID] )
                    && [AssetID]
                        IN VALUES ( 'Value'[AssetID] )
                            && [AssetID] IN filterassetid
        ),
        [OwnershipPercentage]
    )
RETURN
    ( maxvalue + subvalue * ownerper ) * ownerper
Measure2 =
VAR a =
    ADDCOLUMNS (
        SUMMARIZE ( ALLSELECTED ( 'Value' ), [AssetID] ),
        "Measure", [Measure]
    )
RETURN
    SUMX ( FILTER ( a, [AssetID] IN VALUES ( 'Value'[AssetID] ) ), [Measure] )

 

Then put the measure2 to the card.

Output

vxinruzhumsft_0-1727078154779.png

Best Regards!

Yolo Zhu

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

 

 

parry2k
Super User
Super User

@ARWCL very hard to tell from DAX expressions. It will be easier if you share pbix file using one drive/google drive with the expected output. Remove any sensitive information before sharing.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

See below images of the test tables and Power BI report i have tried to create. Should be really easy to replicate and test. Thank you

POWER BI TEST.jpg

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.