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
Anonymous
Not applicable

Complicated Dax

I am trying to have a projection column that in essence will say and do the following:

 

If a pay period has occured and not blank use what exists for that given month, if the pay period hasnt occured and is in the future assume it will use average of existing pay periods of that year.  my formula is as follows:  What is bolded is what needs to change.

 

Personnel=
SUMX (
    VALUES ( 'Calendar'[Month Name] ),
    IF (
        CALCULATE (
            SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
            '6. Actuals'[Actuals],
            'Calendar'[Year] = 2022,
            '5. Chart of Accounts'[Object Category] = "Personnel",
            'Pay Period'[Pay Period] = "Yes"
        ) * -1
            = BLANK (),
        CALCULATE (
            SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
            '6. Actuals'[Actuals],
            'Calendar'[Year] = 2021,
            '5. Chart of Accounts'[Object Category] = "Personnel",
            'Pay Period'[Pay Period] = "Yes"
        ) * -1,
        CALCULATE (
            SUMX ( '6. Actuals', '6. Actuals'[Actuals] ),
            '6. Actuals'[Actuals],
            'Calendar'[Year] = 2022,
            '5. Chart of Accounts'[Object Category] = "Personnel",
            'Pay Period'[Pay Period] = "Yes"
        ) * -1))
 
What it should be is lets say we have been paid for 10 pay periods with the average being 10$; pay periods 11-26 should display $10.
 
Thanks for help I think what is throwing off is values formula at start and my inability to get the average to work in this appropratiely.
4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Ideally what should be in bolded is the verbal version of 

 

Average of 2022 Actuals that occured on a pay period date that are personnel expenses.

Hi @Anonymous.

You can try to use the following measure formula if it is suitable for your requirement:

Personnel =
SUMX (
    VALUES ( 'Calendar'[Month Name] ),
    CALCULATE (
        VAR currPay =
            MAX ( Table[pay period] )
        RETURN
            IF (
                CALCULATE ( SUM ( '6. Actuals'[Actuals] ), 'Calendar'[Year] = 2022 )
                    = BLANK (),
                CALCULATE (
                    IF (
                        currPay >= 11
                            && currPay <= 26,
                        10,
                        IF (
                            currPay = 10,
                            AVERAGE ( '6. Actuals'[Actuals] ),
                            SUM ( '6. Actuals'[Actuals] )
                        )
                    ),
                    'Calendar'[Year] = 2021
                ),
                CALCULATE (
                    IF (
                        currPay >= 11
                            && currPay <= 26,
                        10,
                        IF (
                            currPay = 10,
                            AVERAGE ( '6. Actuals'[Actuals] ),
                            SUM ( '6. Actuals'[Actuals] )
                        )
                    ),
                    'Calendar'[Year] = 2022
                )
            ),
        '6. Actuals',
        '5. Chart of Accounts'[Object Category] = "Personnel",
        'Pay Period'[Pay Period] = "Yes"
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

I think this is close!  What I want is instead of 1 appearing like we have in the above formula (i think you have ten) I would want the current year's average to appear at all the Blank pay dates that are "Yes" that have not occured.  Addiitionally the summing of the formula should equal roughly 70m not 503m but I have not figured out why that is summing that way.  Also, I tried replacing the 1 with an average formula but that did not work either.

 

JMcAnarney_0-1661124733356.png

 

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.