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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ExcelMonke
Super User
Super User

SUMX Help - error in syntax?

Hello,
I am having some trouble with SUMX. My intended result seems to work in Excel - but not in Power BI. What i need to do, is effectively sum all the individual pieces in the column for each day. In this case, the total sum for 10/3/2023 should be 480, but it is showing 920. See the first screenshot below.

Screenshot 1:

ExcelMonke_1-1719604596997.png

The DAX For this is as follows:

 

 

Max Slot Length =
VAR _MaxSlot =
    CALCULATE (
        MAX ( 'Table'[SlotLength] ),
        FILTER (
            'Table',
            'Table'[Include/Exclude] = "Include" 
        ),
        ALLEXCEPT (
            'Table',
            'Table'[SlotDate],
            'Table'[SlotTime]
        )
    )
VAR _SumTable =
    SUMMARIZE (
        'Table',
        'Table'[SlotDate],
        'Table'[SlotTime],
        "Max Length", _MaxSlot
    )
RETURN
    CALCULATE (
        SUMX ( _SumTable, [Max Length] ),
        ALLEXCEPT ( 'Table', 'Table'[SlotDate] )
    )

 

 

 

The intended result is this:

ExcelMonke_2-1719604841868.png

Can anyone help me with this?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





4 REPLIES 4
DataNinja777
Super User
Super User

Hi @ExcelMonke ,

 

What about sumxing your result over the SlotTime field like below? 

Max Slot Length =
VAR _MaxSlot =
    CALCULATE (
        MAX ( 'Table'[SlotLength] ),
        FILTER ( 'Table', 'Table'[Include/Exclude] = "Include" ),
        ALLEXCEPT ( 'Table', 'Table'[SlotDate], 'Table'[SlotTime] )
    )
VAR _SumTable =
    SUMMARIZE (
        'Table',
        'Table'[SlotDate],
        'Table'[SlotTime],
        "Max Length", _MaxSlot
    )
RETURN
    SUMX (
        VALUES ( 'Table'[SlotTime] ),
        CALCULATE (
            SUMX ( _SumTable, [Max Length] ),
            ALLEXCEPT ( 'Table', 'Table'[SlotDate] )
        )
    )

 Best regards,

Thank you for the suggestion! Unfortunately this overestimates it even more (See Max Slot Length2)

ExcelMonke_0-1719847982120.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi,@ExcelMonke. I am glad to help you.
Hello,@DataNinja777 ,thanks for your concern about this issue.

Has your problem been solved yet, if not, can you provide a .pbix file that does not contain sensitive data, this will help to solve your problem.

Could you please check if your measure calculations are due to an incorrect current calculation environment, and secondly check the code itself to see if there are any problems. Because the filter settings including the relationship filter between tables in the model will also affect the measure calculation result.

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

Best Regards,

Carson Jian,

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



Hello,

Unfortunately I am unable to share the relatively complex PBIX. I am hoping there's a relatively simple solution to this SUMX issue I am facing. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.