Forum Discussion

mkinal's avatar
mkinal
Regular Visitor
4 years ago

Measure result differs based on order applied onto visual

Hi All,

 

I have a wierd problem: the result of two measures depend on the order they are applied onto a Matrix visual. Could this be a storage engine bug? If I change the order of the measure after they were applied onto the visual, nothing happens. I have to delete one measure and apply back again for the changes to take effect.

 

Here are my tables:

 

Here's the first result:

 

And here's the second one:

 

And heres' my DAX:

 

 

Article Motive Count =
COUNTROWS ( article_motives )

 

 

 

Aftersales Motives = 
    VAR PackageSelection2 = {"P6 - Backpack"} --,"P2 - Subpart","P6 - Backpack","P9 - Shoe","P10 - Accessory"}
    VAR RelevantPackages2 =
        CALCULATETABLE(
            article_packages,
            packages[name] IN PackageSelection2
        )
    VAR RelevantMotives2 =
        CALCULATETABLE(
            VALUES( package_motives[motive_id] ),
            RelevantPackages2
        )
    VAR MotivesNeeded2 =
        CALCULATE(
            [Article Motive Count],
            TREATAS( RelevantMotives2, article_motives[motive_id])
        )
    RETURN
        MotivesNeeded2

 

 

 

Pre-sales Motives = 
    VAR PackageSelection = {"P1 - Toppart","P2 - Subpart","P6 - Backpack","P9 - Shoe","P10 - Accessory"}
    VAR RelevantPackages =
        CALCULATETABLE(
            article_packages,
            packages[name] IN PackageSelection
        )
    VAR RelevantMotives =
        CALCULATETABLE(
            VALUES( package_motives[motive_id] ),
            RelevantPackages
        )
    VAR MotivesNeeded =
        CALCULATE(
            [Article Motive Count],
            TREATAS( RelevantMotives, article_motives[motive_id])
        )
    RETURN
        MotivesNeeded

 

 

 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi mkinal ,

     

    This should be caused by your data model. Which one is the correct subtotal, first one or second one? Or both of them are incorrect.

    Could you share a sample file with me and show the result you want? This  will make me easier to find the solution.

     

    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.

  • mkinal's avatar
    mkinal
    Regular Visitor

    Hi Anonymous !

     

    Thanks for the reponse!

     

    To make things a bit more clear here are my steps:

    1. Apply 'Aftersales Motives' measure onto the visual. Result: 249 - good result

    2. Apply 'Pre-Sales Motives' measure onto the visual. Result: 249 - wrong result

    3. Remove the two measures from the visual

    4. Apply 'Pre-Sales Motives' measure onto the visual. Result: 1392 - good result

    5. Apply 'Aftersales Motives' measure onto the visual. Result: 1392 - wrong result

     

    So basically the measure applied second takes the value of the one applied first. If I change the order in the Visualizations pane, that doesn't change the results, only if I remove the measure that was applied first.

     

    Here's the sample file: https://we.tl/t-XAMvYX6G0c

     

    Best,

    Marcrell

     

  • mkinal's avatar
    mkinal
    Regular Visitor

    Hi there!

     

    Anyone has any idea why this could happen?