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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
antonioaceituno
Frequent Visitor

Aggregation to avoid accounting twice

Hi,

 

I was wondering if any of you may help me with one sintaxis issue I have:

 

I have one table in my datasert: Column A: Country: Spain, Italy, England. Column B:Date (dd/mm/yyyy), Column C: Daily target, Column 😧 Element Related.

 

DailyT arget would be equal in all the rows as long as the Day of the year and Country are the same. No matter the Element. 1 Target per day and country

 

I.e:

Spain // 1-1-18 // 50 // Generator

Italy // 1-1-18 // 40 // Cables

England // 1-1-18 // 30 // Fuses

Spain // 1-1-18 // 50 // Fuses

Spain //1-1-18 // 50// Blade

Italy // 2-1-18 // 5 // Generator

England // 2-1-18 // 15 // Blade

Spain //2-1-18 // 12 // Cables

Spain //2-1-18 // 12 // Fuses

...

 

 

If I Filter by Spain & Italy, & the January 1st, I should get 90 (50:Daily target for Spain, + 40: Daily target for Italy).

NOT 50+40+50+50. 

 

If I filter by Spain, and 1st and 2nd Jan, I should get 62 (50: 1st Jan Target for spain + 12: 2nd Jan Target for Spain). NOT 50+50+50+12+12

 

Do I have to create a new measure? and how? I was told to use SUMX and DISTINCT function but I dont really get it and dont know how to create it

 

Or do I have to create a new column instead? How it would be?

 

Thank you so much in advance!

 

2 ACCEPTED SOLUTIONS

Thank you so much for your help!

 

It almost works, but it does not when I select different dates at the same time. Selecting more days creates conflict. 

 

When selecting Spain & Italy days 1 & 2, the result should be

Day 1: 50+40

Day 2: 12+5

Result: 90+17=107

 

However, the "Card plot" says "MdxScript(Model) (3,70) Calculation error in measure 'Table1[Measure]: A table of multiple values was supplied where a single value was expected"

 

Thank you so much again!

 

View solution in original post

HI @antonioaceituno

 

Try this revised MEASURE

 

Measure =
SUMX (
    SUMMARIZE ( ALLSELECTED ( Table1 ), Table1[Country], Table1[Date] ),
    CALCULATE ( DISTINCT ( Table1[Daily Target] ) )
)

View solution in original post

6 REPLIES 6
Zubair_Muhammad
Community Champion
Community Champion

Hi @antonioaceituno

 

Try this MEASURE

 

Measure =
SUMX (
    ALLSELECTED ( Table1[Country] ),
    CALCULATE ( DISTINCT ( Table1[Daily Target] ) )
)

Thank you so much for your help!

 

It almost works, but it does not when I select different dates at the same time. Selecting more days creates conflict. 

 

When selecting Spain & Italy days 1 & 2, the result should be

Day 1: 50+40

Day 2: 12+5

Result: 90+17=107

 

However, the "Card plot" says "MdxScript(Model) (3,70) Calculation error in measure 'Table1[Measure]: A table of multiple values was supplied where a single value was expected"

 

Thank you so much again!

 

HI @antonioaceituno

 

Try this revised MEASURE

 

Measure =
SUMX (
    SUMMARIZE ( ALLSELECTED ( Table1 ), Table1[Country], Table1[Date] ),
    CALCULATE ( DISTINCT ( Table1[Daily Target] ) )
)

Thank you! so useful! Smiley Happy

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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