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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jjohnson1990
Frequent Visitor

Sum for filtered in distinct value

HELLO ALL,


I currently have a table with below for columns.

SecSECTORDATEDEP DLY MINPAXDEP DELAY CODE
51/1/20 0:002016715 - PH
81/1/20 0:008516791 - RL
101/1/20 0:001516293 - RA
161/1/20 0:0010513193 - RA
161/1/20 0:0010513131 - GD
211/1/20 0:001515985 - AS
231/1/20 0:001915493 - RA
231/1/20 0:001915434 - GS
241/1/20 0:003513193 - RA
     

 

I need to first calculate the sum of pax for the distinct Sectorkey column based on a condition and display the figure in card visualization.

Used the below dax query but could not get the exact answer.

 

Total PAX =
SUMX (DISTINCT('Query1'[Sectorkey],(Query1[PAX]))

 

if someone can help me , if you need more informations plese tell me.

1 ACCEPTED SOLUTION

Hello @az38 , thanks for the revert. i had run your code, it give me a constant value regardless of date 

On modifying the code slightly i.e. removing the filter expression ALL(Query), this gave me the correct output as expected

 

Total PAX = CALCULATE(SUMX(SUMMARIZE('Query1','Query1'[Sec], "Total PAX", MAX(Query1[PAX])), [Total PAX]))

 

 

 

 

View solution in original post

7 REPLIES 7
az38
Community Champion
Community Champion

Hi @jjohnson1990 

I completely do not understand what is your desired output based on your datasample?

if you need sum by sectorkey you can create a measure like

CALCULATE(SUM(Query1[PAX]), ALLEXCEPT(Query1, Query1[SectorKey]) )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hello @az38 , thanks for the revert. i had run your code, it give me a constant value regardless of date 

On modifying the code slightly i.e. removing the filter expression ALL(Query), this gave me the correct output as expected

 

Total PAX = CALCULATE(SUMX(SUMMARIZE('Query1','Query1'[Sec], "Total PAX", MAX(Query1[PAX])), [Total PAX]))

 

 

 

 

Hi @jjohnson1990 

 

I noticed that except the column CODE the rest of the values for duplicat SEC are the same! why don<t you just try to remove the Duplicate rows from your table and do the SUM?

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

hello @aj1973,

the above table is only a synopsis of the table data. the duplicate data comes due to a left join condition in sql which cannot be avoided due to data beign pulled in from other tables.

@jjohnson1990 

 

doesn't matter how it is linked in the source SQL. If you are willing to remove the duplicate then use Power query in query editor to clean and transform your data. Remember, for performance purposes you need to clean, get rid of none necessary data and transform data in Query Editor to get the most in your visuals and the use of DAX in the Power BI desktop.

 

Regards 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hello @az38 ,

you would see wihtin the table that the row for sectorkey [Sec] is duplicated for sectorkey= 16 and 23, where PAX value is also duplicated. 

for sum(pax) , i want to take only of the duplicate values, that is distinct(sectorkey). i believe allexcept would totoally remove that sectorykey values, but i need to take only one (or distinct ) of it.

@jjohnson1990 

if I understand your needs correct, try a measure

Total PAX = 
CALCULATE(SUMX(SUMMARIZE('Query1','Query1'[Sec], "Total PAX", MAX(Query1[PAX])), [Total PAX]), ALL(Query1))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors