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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Sum of number of columns based on variable

Does anyone knows how to write in DAX to tell power bi to add up all of the values in the range of cells that is determined by the value of the cell "LT" in the same row

 

Yip_0-1672298364683.png

 

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Please check the reply from @TomasAndersson  first. If that does not help .

 

I think double = is causing it 

 

for var you need code like

 

=

var _variable = sumx(Table, [Value])

return

_variable

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
TomasAndersson
Solution Sage
Solution Sage

Hi!
If you are able to change the structure of your data the easiest way would be to make your table long instead of wide so that you only have four columns, "Demand...", "LT", "Variable","Value".

You can do that in Power Query if you go to the model view, select Edit query and then under Transform select "Unpivot columns" with all your columns with values selected:

TomasAndersson_0-1672300288908.png

If you control your data source you might be able to do it there as well.

Then you could only use a simple SUM(Value) to find the totals.

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors