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
DRA885
Frequent Visitor

MEDIANX missing values for dates with no data

Hello all.

 

I'm looking for some help on this DAX code:

 

 

Median Test 3 (next 3 months approved) = 
VAR MedianValueDiscipline =
    CALCULATE (
        MEDIANX (
            SUMMARIZE (
                'Actual & Forecast Project Resources',
                'Actual & Forecast Project Resources'[Work Week Ending Date],
                'Actual & Forecast Project Resources'[Capsule Descriptions.Discipline],
                "Median FTEs",
                    SUMX (
                        'Actual & Forecast Project Resources',
                        'Actual & Forecast Project Resources'[Consolidated FTEs]
                    )
            ),
            [Median FTEs]
        ),
        'Actual & Forecast Project Resources'[Final Consolidated Hours Type] = "Approved",
        DATESINPERIOD (
            'Actual & Forecast Project Resources'[Work Week Ending Date],
            MAX ( 'Date'[EndOfThisWeek] ) - 1,
            3,
            MONTH
        )
    )
RETURN
    MedianValueDiscipline

 

 

 
This is producing the following results in a matrix:
Median - next 3 months.png
Whilst this is giving the correct total value, the rows with null values are incorrect as the Median is only calculating for dates where there is a value. The rows with 'blanks' are from the field 'Actual & Forecast Project Resources'[Capsule Descriptions.Level Category]
 
My question is, how can I force zero values into the 'blanks' and obtain the correct result for each row of the matrix?
 
TIA, Ian
3 REPLIES 3
IrenaId
Frequent Visitor

@DRA885 , did you manage to solve this? I am currently fasing the same problem.

DRA885
Frequent Visitor

Sorry thought I had the solution but this is still incorrect.
Obviously now still looking for a solution to this

DRA885
Frequent Visitor

solved with the following change to the Sum calculation of FTEs:

Median Test 3 (next 3 months approved) =
VAR MedianValueDiscipline =
    CALCULATE (
        MEDIANX (
            SUMMARIZE (
                'Actual & Forecast Project Resources',
                'Actual & Forecast Project Resources'[Work Week Ending Date],
                'Actual & Forecast Project Resources'[Capsule Descriptions.Discipline],
                "Median FTEs",
                    IF (
                        CALCULATE (
                            SUM ( 'Actual & Forecast Project Resources'[Consolidated FTEs] ),
                            'Actual & Forecast Project Resources'[Final Consolidated Hours Type] = "Approved"
                        ) > 0,
                        CALCULATE (
                            SUM ( 'Actual & Forecast Project Resources'[Consolidated FTEs] ),
                            'Actual & Forecast Project Resources'[Final Consolidated Hours Type] = "Approved"
                        ),
                        0
                    )
            ),
            [Median FTEs]
        ),
        DATESINPERIOD (
            'Actual & Forecast Project Resources'[Work Week Ending Date],
            MAX ( 'Date'[EndOfThisWeek] ) - 1,
            3,
            MONTH
        )
    )
RETURN
    MedianValueDiscipline

 

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