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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
reachkrs
Frequent Visitor

Measure to calculate hours & $ of distinct value in a column

Hi

I am new to this forum & also to DAX. I have a Power BI model with data in columns A, B, C & D. I want to calculate the sum using a measure to sum as it appears in columns E & F. These are sums of columns C & D based on column A. Column A can repeat but I want to calculate it only once. Also, I want to calculate the Average & Median of these calculated measures. How to get this using DAX.

Seeking help from the community on how to address this and get the desired result.

reachkrs_0-1657108584644.png

 

3 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@reachkrs ,

 

Try measures like

 

Sumx(summarize(Table, Table[Project], Table[Hour]), [Hour])

 

Sumx(summarize(Table, Table[Project], Table[$]), [$])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

v-cazheng-msft
Community Support
Community Support

Hi @reachkrs ,

 

Not quite sure about the calculated logic of Sum Measure Result Hours. But you may try the following Measures.

vcazhengmsft_0-1657779786697.png

 

 

Result $ Measure =
VAR minLine =
    CALCULATE (
        MIN ( 'Table'[Line] ),
        ALLEXCEPT ( 'Table', 'Table'[Project], 'Table'[Hour] )
    )
VAR NotRepeat =
    IF ( MAX ( 'Table'[Line] ) = minLine, MAX ( 'Table'[$] ), 0 )
RETURN
    NotRepeat

 

 

 

Sum Measure Result $ = SUMX('Table',[Result $ Measure])

 

 

 

Average Sum $ = AVERAGEX('Table',[Sum Measure Result $])

 

 

 

Median Sum $ = MEDIANX('Table',[Sum Measure Result $])

 

 

The result looks like this.

vcazhengmsft_1-1657779786702.png

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

Hi

Thank you.  The code provided by you gives exact result.

This solves my problem.

 

View solution in original post

4 REPLIES 4
v-cazheng-msft
Community Support
Community Support

Hi @reachkrs ,

 

Not quite sure about the calculated logic of Sum Measure Result Hours. But you may try the following Measures.

vcazhengmsft_0-1657779786697.png

 

 

Result $ Measure =
VAR minLine =
    CALCULATE (
        MIN ( 'Table'[Line] ),
        ALLEXCEPT ( 'Table', 'Table'[Project], 'Table'[Hour] )
    )
VAR NotRepeat =
    IF ( MAX ( 'Table'[Line] ) = minLine, MAX ( 'Table'[$] ), 0 )
RETURN
    NotRepeat

 

 

 

Sum Measure Result $ = SUMX('Table',[Result $ Measure])

 

 

 

Average Sum $ = AVERAGEX('Table',[Sum Measure Result $])

 

 

 

Median Sum $ = MEDIANX('Table',[Sum Measure Result $])

 

 

The result looks like this.

vcazhengmsft_1-1657779786702.png

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Hi

Thank you.  The code provided by you gives exact result.

This solves my problem.

 

reachkrs
Frequent Visitor

Thank you Amit.  Sumx works perfectly. 

 

Is it possible to calculate average & median of these values ?.  Since these are Measures Median, Average functions do not accept these as parameters.

amitchandak
Super User
Super User

@reachkrs ,

 

Try measures like

 

Sumx(summarize(Table, Table[Project], Table[Hour]), [Hour])

 

Sumx(summarize(Table, Table[Project], Table[$]), [$])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.