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
rajuctech
Frequent Visitor

Category wise sum in table

Hi all,

 

i have a below query sum up the category wise value, but the DAX is not giving the correct results.

rajuctech_0-1656050090847.png

 

L2_L5_Sum =
var P=SELECTEDVALUE('Calander'[Year])
var a=CALCULATE(SUM('tbl'[Value]),'tbl'[Category]="L2")
var b=CALCULATE(SUM('tbl'[Value]),'tbl[ategory]="L3")
var c=CALCULATE(SUM('tbl'[Value]),'tbl'[Category]="L5",'Calander'[Year]=P)
var x=a+b+c
Return
x

 

Any suggestion would be fine.

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @rajuctech,

 

You may try this Measure.

SumOfVal = CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Category] IN {"L2","L3","L4","L5"}))

 

The result looks like this.

vcazhengmsft_0-1656380187295.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

5 REPLIES 5
v-cazheng-msft
Community Support
Community Support

Hi @rajuctech,

 

You may try this Measure.

SumOfVal = CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Category] IN {"L2","L3","L4","L5"}))

 

The result looks like this.

vcazhengmsft_0-1656380187295.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Thank you very much msft, it's working fine.

rajuctech
Frequent Visitor

the above one is not working, sumx(table and Expression only)

try this then:

CALCULATE ( SUM( 'Table '[ValueS] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Category ] = MAX ( 'Table'[Category ]  && [Category ="L2") ) )

NilR
Post Patron
Post Patron

try  sumx
var a=CALCULATE(SUMX('tbl'[Category], [Values]),'tbl'[Category]="L2")

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.

Top Solution Authors