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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
enestkm
Frequent Visitor

Adding subtotals by categories as a column

Hi,
I am trying to add a column to a table which calculates the subtotals by categories and repeats it on every row.
It is the last column on the right-hand side that should sum up the visit_count column by user and visit_year and write it to last column by repeating it for every user/year
I have tried SUMX but could not figure it out ,


Many thanks in advance Annotation 2020-01-22 130401.jpg

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @enestkm 

try a measure

Measure = CALCULATE(SUM([Visit_Count]), ALLEXCEPT('Table', 'Table'[User], 'Table'[Visit_Year]))

 

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


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

View solution in original post

6 REPLIES 6
az38
Community Champion
Community Champion

Hi @enestkm 

try a measure

Measure = CALCULATE(SUM([Visit_Count]), ALLEXCEPT('Table', 'Table'[User], 'Table'[Visit_Year]))

 

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


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

thanks @az38 , however i need it as a column to use as X-axis on a visual

az38
Community Champion
Community Champion

@enestkm 

column with the same statement should work too. check

but measure is preffered and Im not sure your visuals will be correct in any use cases if you will use a column

 

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


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

thanks @az38 , it worked perfectly 

is this can be replicated as a custom column in query editor?

az38
Community Champion
Community Champion

@enestkm 

power query editor mission is data cleansing and transformation, all business logic should be calculated in DAX

maybe, you can create some M code that could calculate, but it will be not only not the best practice, but the worst practice

 

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


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

that totally makes sense, many thanks @az38 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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