Forum Discussion

whatlje1's avatar
whatlje1
Regular Visitor
6 years ago

Dax Calculations

I am trying to do some Calculations to figure out "Wage" based on certain Criteria. Here is what I have:

SUMX(
    'Federal Holidays',
    SWITCH(
        TRUE(),
    'Federal Holidays'[Holiday] = "New Year's Day 3 Days After" || 'Federal Holidays'[Holiday] = "New Year's Day 3 Days Before",
            IFERROR(
                CALCULATE(
                Round( [_hours],0) * [_estimatedWageAverage]
                ,'PTO/VTO/OTAppendNICEtoCalabrio'[_exception] IN {"VTO" , "Voluntary Time Off (VTO)"}
                ,Dates[month index] > -16
                ,Dates[month index] < -1
                ),0
            )  
    ,'Federal Holidays'[Holiday] <> "New Year's Day 3 Days After" || 'Federal Holidays'[Holiday] <> "New Year's Day 3 Days Before",
            IFERROR(
                CALCULATE(
                Round( [_hours],0) * [_estimatedWageAverage]
                ,'PTO/VTO/OTAppendNICEtoCalabrio'[_exception] IN {"VTO" , "Voluntary Time Off (VTO)"}
                ,Dates[year index] = 0
                ),0
            )
    )
)
What I need to remove is the SUMX part. I cannot figout another way to do this calculation.
 
What I am looking to do in one Formula, is to do something like this(I did Merge my Federal Holiday table to my Main Table):
_estimatedSavingsCurrentYear2 =
IF('PTO/VTO/OTAppendNICEtoCalabrio'[Holiday Name] = "New Year's Day 3 Days After" || 'PTO/VTO/OTAppendNICEtoCalabrio'[Holiday Name] = "New Year's Day 3 Days Before",
            IFERROR(
                CALCULATE(
                Round( [_hours],0) * [_estimatedWageAverage]
                ,'PTO/VTO/OTAppendNICEtoCalabrio'[_exception] IN {"VTO" , "Voluntary Time Off (VTO)"}
                ,Dates[month index] > -16
                ,Dates[month index] < -1
                ),0
            ),
            IFERROR(
                CALCULATE(
                Round( [_hours],0) * [_estimatedWageAverage]
                ,'PTO/VTO/OTAppendNICEtoCalabrio'[_exception] IN {"VTO" , "Voluntary Time Off (VTO)"}
                ,Dates[year index] = 0
                ),0
            )
    )
 
 
'PTO/VTO/OTAppendNICEtoCalabrio'[Holiday Name] is a Column within the table.
 
 

1 Reply

  • Hey whatlje1 ,

     

    It's no disgrace to publish sample data. Especially if you want help with DAX formulas and the helping persons have to test their formulas themselves in order not to give any wrong answer or to guess blindly.

     

    So may I ask you, if you ask for help from others, to also fulfill your contribution and provide sample data?

     

    BR,

    Josef