Forum Discussion

BalajiBuddha's avatar
BalajiBuddha
Frequent Visitor
4 months ago
Solved

Stock month showing wrong values due to adding two fields into the table visual

Hi All Stock month values showing wrong values when i add two fields into the table visual "Reorder Point","Minimum lot size" if i remove two fields in to the table data showing correct, he...
  • grazitti_sapna's avatar
    4 months ago

    Hi BalajiBuddha,

     

    The issue is that when you add these two columns in the table visual, they change the row level granualirity of the calculation and your measure Stock Month gets recalculated at a more detailed level.

     

    To fix this your measure should ignore  Reorder Point & Minimum Lot Size context.

     

    Update your dax is such a way:-

     

    Try below dax

     

    Stock Month =
    DIVIDE(
    CALCULATE(
    [Total Value in Stock Local],
    REMOVEFILTERS('YourTable'[Reorder Point], 'YourTable'[Minimum Lot Size])
    ),
    CALCULATE(
    [COGS 12 month moving average Local],
    REMOVEFILTERS('YourTable'[Reorder Point], 'YourTable'[Minimum Lot Size])
    )
    )

     

    Alternatively you can also achieve it with ALLEXCEPT function

     

    Stock Month =
    DIVIDE(
    CALCULATE(
    [Total Value in Stock Local],
    ALLEXCEPT('Stock Healthiness', 'Stock Healthiness'[Material], 'Stock Healthiness'[Plant])
    ),
    CALCULATE(
    [COGS 12 month moving average Local],
    ALLEXCEPT('Stock Healthiness', 'Stock Healthiness'[Material], 'Stock Healthiness'[Plant])
    )
    )

    If it still doesn;t work look at your relationship setup and try to use the correct relationship in your measure using USERELATIONSHIP() function.

     

     

    ๐ŸŒŸ I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
    ๐Ÿ’ก Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
    ๐ŸŽ– As a proud SuperUser and Microsoft Partner, weโ€™re here to empower your data journey and the Power BI Community at large.
    ๐Ÿ”— Curious to explore more? [Discover here].
    Letโ€™s keep building smarter solutions together!