cancel
Showing results for
Did you mean:  Post Patron

## Use Summarize and then sum with an allexcept

Hi,

I need a measure to remove some duplicates and then sum one column grouped by another column

So the first step is the summarize and the second step which is not possible since ALLEXCEPT function does not allow for a table expression:

So here's  what I got so far:

totalbyCountry_without_duplicates =
VAR _summary =

summarize (table1,start_date,totalByStartDate)

RETURN

SUMX ( ALLEXCEPT(_summary,start_date),total)

Simplified Sample Data:

Columns :
Start_date, end_date, totalByStartDate, totalbyEndDate, Product

 1-Jan 1-Feb 20 10 A 1-Jan 1-Mar 20 5 A 1-Feb 1-Mar 50 18 A 1-Feb 1-Apr 50 9 A 1-Jan 1-Feb 10 8 B 1-Jan 1-Mar 10 2 B 1-Feb 1-Mar 40 12 B 1-Feb 1-Apr 40 6 B

7 REPLIES 7  Post Patron

I created a new table with my summarize function.

And then created a measure with the ALLEXCEPT and it worked fine. But i dont want to go through this solution because of the unecessary sspace that im creating  Community Support

I guess the function summarizecolumn also works for you：

calculated table:

``````Table =
SUMMARIZECOLUMNS (
table1[start date],
table1[totalByStartDate],
"Total", SUM ( table1[totalbyEndDate] )
)
``````

Please check my  sample pbix file for more details.

If I misunderstand,please let me know

Best Regards,
Community Support Team _ Eason  Post Patron

So I need three things:

1. It needs to be in a measure (no table , no calculated columns)

2. It needs to summarize (which you have done)

3. It needs to have the same concept of ALLEXCEPT where the amounts are aggregated by group

Thats because I have several other columns in my actual model. For the sake of simplicity I only kept a minimum amount of columns. But if I had product, city, region and other dimensions. I'd need an allexcept function to allow the aggregation to be done for the entire group

I've updated my sample data in the question  Post Patron

Heres the issue with my actual data

I need the column Measure A_NUM to be divided by the total of Measure A_DEN (9998)

Measure A_DEN =
sumx(summarize('table',dimA,dimB,dimC,dimD,sumTotal),sumTotal)

but if i take Measure A_NUM divided by Measure A_DEN i get 4293/9346 for recurring_date of Feb 2021.   Super User IV

@RogerSteinberg , Try a measure like

calculate(sumx(values(total[total]),calculate(max([total]))), allexcept(Table, Table[start Date]))

Proud to be a Super User!  Post Patron

Measure B : your suggestion formula

Measure A: What I had done

What i need is the subtotal from Measure A to appear in each row as such:

9998

9998

9998

...   Post Patron

The idea is there but the value that I'm getting isn't right. I am not completely sure but the issue seems to come from the "VALUES" function which takes the distinct values of total.

For the sake of simplicity , my sample data only had a few columns. But my model has over 8 columns with millions of rows grouped by month for the past 4 years. For example, if , for one permutation i have a total amount of 10 for start_date Jan 1 2020 and another different permutation for the same date with the same exact amount, then I should keep both values even if they are the same. I think that using your measure it removes one of them correct? Announcements #### Welcome to the User Group Public Preview  