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

Dynamic weighted median for Income

Hello...

I have the following prosedure to calculate median as SSPS algorithim do but Dynamicly through DAX

 all families must have value for all Income categories if the no income then record it by 0

so the Data Shape like

Family_IDINCOME_CATINCOME_DESCVALUEWeighted MEMBERS NUMBERUnWeighted MEMBERS NUMBER
11Main Job200052
12Second Job052
13Real estate300052
21Main Job1000104
22Second Job500104
23Real estate5000104

 

A- find Per Capita Income:

1- Sum the income value for each Family/UnWeighted MEMBERS NUMBER

2- Step 1 * Weighted MEMBERS NUMBER

3- Step 2/(Total distinct Weighted MEMBERS NUMBER)

 

the equation that give right result and its totaly dynamic is :

:=
SUMX (
    SUMMARIZE (
        FACT_HOUSEHOLD_INCOME,
        FACT_HOUSEHOLD_INCOME[FAMILY_ID],
        "M"AVERAGE ( FACT_HOUSEHOLD_INCOME[Memebers_Number] ),
        "Wi"AVERAGE ( [wi] ),
        "IN"SUMX (
            SUMMARIZE (
                FACT_HOUSEHOLD_INCOME,
                FACT_HOUSEHOLD_INCOME[FAMILY_ID],
                FACT_HOUSEHOLD_INCOME[INCOME_CAT],
                "INN"SUM ( FACT_HOUSEHOLD_INCOME[VALUE] )
            ),
            [INN]
        )
    ),
    IF ( [m] <> 0, ( ( [IN] / [M] ) * [Wi] )0 )
)/CALCULATE([Total Members],all(DIM_Family_CAT))

 

that was a Per Capita Income

I need help finding Median which is

1- Sort Families by Per Capita Income from lowest to highst

2-sum a cumulative (Weighted MEMBERS NUMBER)/max(cumulative (Weighted MEMBERS NUMBER))*100

3- from step 3 take the nearst value to 50

 

can any one help me to use the previous equation to reach the median and to be dynamic for the Category and family

 

thanks in advance

1 REPLY 1
v-danhe-msft
Employee
Employee

Hi @Anonymous,

From your description, I could not understand below sentence:

1- Sort Families by Per Capita Income from lowest to highst
What is the desired result from this step?

2-sum a cumulative (Weighted MEMBERS NUMBER)/max(cumulative (Weighted MEMBERS NUMBER))*100

Is this step get the value from ((5+5+5+10+10+10)/(2+2+2+4+4+4))*100=250?

3- from step 3 take the nearst value to 50

If above steps are step 1 and step 2, what step is step 3?

Could you please offer me more information and post your desired result?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.