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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
DGodQc
Frequent Visitor

Calculate sum with a distinct filter

Hello community,

 

I have problems calculating an availability % for my production. Here is my formula at the moment:

Availability = (sum(V_COMB_PROD_CRW1[PROD_HRS])/((sum(V_COMB_PROD_CRW1[PROD_HRS])+sum(V_COMB_PROD_CRW1[TOTAL_DOWNTIME_HRS]))-sum(V_COMB_PROD_CRW1[PLANNED_DOWN_TIME])))*100
powerbi.png
Problem is:  i need to calculate those results, but only one time for each dayprod_ID. I've tried SUMX with distinct formulas, but i can't get the right way to do it.
 
Is there a more advanced user that can give me a hint??
 
Thanks,
Dany
1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @DGodQc ,

 

You could add an index column with query editor. Then use RANKX() function to create a rank column.

rank =
RANKX (
    FILTER ( testTable, testTable[ID] = EARLIER ( testTable[ID] ) ),
    testTable[Index],
    ,
    ASC,
    DENSE
)

Then sum the value where [rank]=1.

Measure =
CALCULATE (
    SUM ( testTable[value] ),
    testTable[rank] = 1,
    ALLEXCEPT ( testTable, testTable[ID] )
)

 

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

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @DGodQc ,

 

You could add an index column with query editor. Then use RANKX() function to create a rank column.

rank =
RANKX (
    FILTER ( testTable, testTable[ID] = EARLIER ( testTable[ID] ) ),
    testTable[Index],
    ,
    ASC,
    DENSE
)

Then sum the value where [rank]=1.

Measure =
CALCULATE (
    SUM ( testTable[value] ),
    testTable[rank] = 1,
    ALLEXCEPT ( testTable, testTable[ID] )
)

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
amitchandak
Super User
Super User

It seems very similar to the sum of the Avg problem. Please refer

https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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