Forum Discussion

KB88's avatar
KB88
Frequent Visitor
1 year ago
Solved

Simulated weighted average payment type

I am trying to use a what-if parameter to make a simulated weighted average payment term measure. I have 2 files, 1 with payment terms and the number of days associated. The other file is the main da...
  • v-kathullac's avatar
    1 year ago

    Hi KB88 ,

    Thank you for reaching out to Microsoft Fabric Community Forum.

    Can you try this i have changed the dax which will sync with date slicer

    SimulatedWAPT_Final = 
    VAR SimVendor = SELECTEDVALUE('SC Data'[Vendor Name])
    VAR SimDays = SELECTEDVALUE('New Payment Term'[New Payment Term Value])
    
    VAR VendorSpendTable =
        FILTER(
            ALLSELECTED('SC Data'),
            'SC Data'[Vendor Name] = SimVendor &&
            NOT ISBLANK('SC Data'[PO Payment Term]) &&
            'SC Data'[PO Payment Term] <> "#"
        )
    
    VAR VendorOriginalWeighted = 
        SUMX(
            VendorSpendTable,
            'SC Data'[Spend] * RELATED('Payment Terms'[DAYS])
        )
    
    VAR VendorSimulatedWeighted =
        SUMX(
            VendorSpendTable,
            'SC Data'[Spend] * IF(ISBLANK(SimDays), RELATED('Payment Terms'[DAYS]), SimDays)
        )
    
    VAR AllFilteredData =
        FILTER(
            ALLSELECTED('SC Data'),
            NOT ISBLANK('SC Data'[PO Payment Term]) &&
            'SC Data'[PO Payment Term] <> "#"
        )
    
    VAR OriginalWeightedTotal =
        SUMX(
            AllFilteredData,
            'SC Data'[Spend] * RELATED('Payment Terms'[DAYS])
        )
    
    VAR AdjustedWeightedTotal =
        IF(
            NOT ISBLANK(SimVendor) && NOT ISBLANK(SimDays),
            OriginalWeightedTotal - VendorOriginalWeighted + VendorSimulatedWeighted,
            OriginalWeightedTotal
        )
    
    VAR AdjustedTotalSpend = 
        CALCULATE(
            SUM('SC Data'[Spend]),
            AllFilteredData
        )
    
    RETURN
    DIVIDE(AdjustedWeightedTotal, AdjustedTotalSpend)
    

     

    Regards,

    Chaithanya.