Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
harirao
Post Prodigy
Post Prodigy

DISTINCTCOUNT and then including Median function in same DAX

Hi Team,
I want to create a measure/column, on distinctcount & median together
Eg: created in Excel

6.PNG7.PNG
Is this possible in power bi.

Regards,

Hari 

2 ACCEPTED SOLUTIONS
v-alq-msft
Community Support
Community Support

Hi, @harirao 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

d1.png

 

You may create measures as below.

DisctinctCount OId = DISTINCTCOUNT('Table'[OpportunityId])
actual_visibility_weeks measure 1 = 
MEDIANX(
    DISTINCT('Table'[actual_visibility_weeks]),
    'Table'[actual_visibility_weeks]
)
actual_visibility_weeks measure 2 = 
IF(
    ISFILTERED('Table'[ID]),
    SUM('Table'[actual_visibility_weeks]),
    MEDIANX(
        ALL('Table'),
        'Table'[actual_visibility_weeks]
    )
)

 

Result:

d2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi, @harirao 

 

You may create a calculated table as below.

Table 2= 
SUMMERIZE(
    'Table',
    'Table'[subregion],
    "Median",
    VALUE(MEDIAN('Table'[actual_visibility_weeks]))
)

 

Here is my data for test.

f1.png

 

Result:

f2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hi, @harirao 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

d1.png

 

You may create measures as below.

DisctinctCount OId = DISTINCTCOUNT('Table'[OpportunityId])
actual_visibility_weeks measure 1 = 
MEDIANX(
    DISTINCT('Table'[actual_visibility_weeks]),
    'Table'[actual_visibility_weeks]
)
actual_visibility_weeks measure 2 = 
IF(
    ISFILTERED('Table'[ID]),
    SUM('Table'[actual_visibility_weeks]),
    MEDIANX(
        ALL('Table'),
        'Table'[actual_visibility_weeks]
    )
)

 

Result:

d2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Allan @v-alq-msft

Thanks for providing the solution, after creating discount and medianx, need to create a table region wise and include drill down option as mentioned  below
please note dashboard will be refreshed every weeks, filter for weekly view.
1.PNG
Regards,

Hari 

Hi, @harirao 

 

You may create a calculated table as below.

Table 2= 
SUMMERIZE(
    'Table',
    'Table'[subregion],
    "Median",
    VALUE(MEDIAN('Table'[actual_visibility_weeks]))
)

 

Here is my data for test.

f1.png

 

Result:

f2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Allan @v-alq-msft,

Thanks for the above solution, by using this i was able to create measure, now i want to include two condition inside the DAX

1st Condition
[actual_visibility_Weeks](>1) should be 1 and above. Highlighted in green
2nd Condition : [actual_visibility_Weeks]=0 &  [0 Visibility exclusion] = "No". Should be included in highlighted in red


Median =
FORMAT(MEDIANX(

SUMMARIZE(Query1,Query1[subregion],Query1[actual_visibility_Weeks],Query1[OpportunityId],"Viswks",
COUNT(Query1[OpportunityId])),
[actual_visibility_Weeks]),0)

Can you please help me to include this conditions in my DAX.
Thank you

Regards,
Hari

Hi, @harirao 

 

You may create a measure as below.

Measure = 
IF(
    SELECTEDVALUE('Table'[actual_visibility_weeks])>0,
    "green",
    IF(
        SELECTEDVALUE('Table'[actual_visibility_weeks])=0,
        "red"
    )
)

 

Then you can click 'subregion'=>'conditional formatting'=>'background color', set as below.

a1.png

a2.png

 

Result:

a3.png

 

Best Regards

Allan

d_gosbell
Super User
Super User

It should be possible. It's hard to be exact with just a screenshot of data, but you should be able to use MEDIANX over the values of the week numbers.

 

= MEDIANX( values( table[1] ) , [actual_visibility_weeks] )

 

But I don't really understand what you mean by your comment of needing to consider the opportunityId as your example excel function is only looking at column B. This may change the first parameter of the MEDIANX as this controls the grain at which the median is calculated.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.