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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
perezco
Advocate III
Advocate III

Dynamic sumx () specific vales from a table

Hi all,

How can I have a dax sumx() function that only sums specific values with specific characteristics?

Desire to have

perezco_2-1646691736253.png

 


 

I'm attempting to have a dynamic sumx() function where only sums data that have  specific characteristic.

The  SubRegion_shift   can be  changing by month.

perezco_3-1646690478779.png

 

Current result

perezco_1-1646691707665.png

 


 


 

Ronas= sumx('Fact - Tbl.all.SMALL, 'Fact - Tbl.all.SMALL'[RONAS])

acd= sumx('Fact - Tbl.all.SMALL, 'Fact - Tbl.all.SMALL'[acd])

Data example

perezco_5-1646690478782.png

 

 

regards

 

1 ACCEPTED SOLUTION

For my particular circumstance, I decided to add an extra column to the query by adding a line of multiple CASE WHEN functions to the sql query.

View solution in original post

8 REPLIES 8
AllisonKennedy
Super User
Super User

@perezco  I haven't read all your conditions, so just hoping to provide you the idea that you can apply to your own data:

 

SUMX ( FILTER ( TableName, TableName[Column1] = "Condition1" && TableName[Column2] = "Condition 2") , TableName[ColumnToSum] )

 

If your conditions change from month to month, are you able to create a mapping table or another column that uses those conditions to flag whether to include the row yes or no in the SUMX, then use that flag column in your FILTER condition.

 

You may also be interested in using an OR filter which is || in Power BII: 

https://excelwithallison.blogspot.com/2021/09/advanced-filter-or-vs-and.html 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thanks, 
That section has already been covered.

example:
CALCULATE
(sumx('table','table'[RONACALLS]),fltr_Qtr,fltr_Weekday_flag,fltr_subregion_shift, FILTER(VALUES('table'),'table'[SubRegion] = "NA"))


@perezco  If that's already covered, then what is your question exactly?

 

The excel table with the conditions, if you can make that more tabular database friendly. For example a column with all the values in your IN {{value1, value2}} conditions, each value needs to be its own cell in the same column. Then you can use DAX VALUES() function and the IN operator in DAX to create those conditions and make them dynamic by getting your raw data condition table set up properly. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

The idea does not appear to be a bad one.
I can do it in the backstage using sql or in the power query editor.
The disadvantage is that this report will require human intervention every time the quarter changes...because the   fltr_Qtr for either of the two possibilities will be manual.

@perezco  Could you add a column for 'Quarter' that filters which conditions should be used each quarter?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Your intervention has made it much easier for me to see things in a more straightforward manner.😁
yes. I have the  'Quarter' column part of this fact table. 👍

@perezco Glad the fog is clearing and it's getting easier - what questions do you still have outstanding? Or can we mark this post as solved? 

 

Feel free to write up a summary of what you did and mark your own post as the solution if that makes the most sense. 🙂 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

For my particular circumstance, I decided to add an extra column to the query by adding a line of multiple CASE WHEN functions to the sql query.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.