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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pawelj795
Post Prodigy
Post Prodigy

SQL formula translate to DAX

Hi, can anyone help me to transform below SQL formula to DAX?:

-------------------------------------------------------------------------------------------------------------------------------------------------------------

QTY and Value Financial

 

    while select sum(Qty), sum(CostAmountPosted), sum(CostAmountAdjustment),sum(costAmountPhysical),

            itemId  from inventTrans index itemIdx

            group by itemId

            where (inventTrans.DateFinancial <= transDate &&

                   inventTrans.DateFinancial != datenull())

        {

 

            if(inventTrans.Qty != 0 || (inventTrans.CostAmountAdjustment + inventTrans.CostAmountPosted) != 0)

            {

                select sum(CostAmountAdjustment) from settlement

                    group by itemId where settlement.ItemId == inventTrans.ItemId &&

                                          settlement.TransDate <= transDate &&

                                          settlement.SettleModel != inventSettlemodel::PhysicalValue;

                            inventTrans.Qty

                          settlement.CostAmountAdjustment + inventTrans.CostAmountPosted

            }

        }

-------------------------------------------------------------------------------------------------------------------------------------------------------------

 

QTY and Value Physical

 

         while select sum(Qty), sum(CostAmountPosted), sum(CostAmountAdjustment),sum(costAmountPhysical),

                         itemId  from inventTrans

                group by itemId

                    where

                  (inventTrans.DateFinancial == dateNull() ||

                  (inventTrans.DateFinancial > transDate)

                   &&

                    (inventTrans.DatePhysical != dateNull() &&

                  inventTrans.DatePhysical <= transDate))

        {

 

                          inventTrans.Qty

                          inventTrans.costAmountPhysical

        }

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

PZ is later than FV

 

        while select sum(Qty), sum(CostAmountPhysical),

            itemId  from inventTrans

                group by itemId

                    where

                    inventTrans.DateFinancial <= transDate &&

                    inventTrans.DateFinancial != datenull() &&

                    inventTrans.DatePhysical > transDate

        {

                          inventTrans.Qty

                          inventTrans.costAmountPhysical

        }

-------------------------------------------------------------------------------------------------------------------------------------------------------------

1 REPLY 1
pawelj795
Post Prodigy
Post Prodigy

up

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors