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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Ngars
Helper I
Helper I

DAX for calculating totals from more that one column

Hi,

 

Im trying to create a measure that calculates a total from multiple columns. For example.

 

#NameType 1Type 2
1BulbasaurGrassPoison
2IvysaurGrassPoison
3VenusaurGrassPoison
4CharmanderFire 
5CharmeleonFire 
6CharizardFireFlying
7SquirtleWater 
8WartortleWater 
9BlastoiseWater 
23EkansPoison 
24ArbokPoison 
16PidgeyNormalFlying

 

Im trying to calculate the total from Type 1 and Type 2.  End result will look something like this 

 

Type Total
Grass3
Fire3
Water3
Poison5
Flying2
Normal1

 

Im fairly new to DAX so any help is much appreciated

Thanks,

Sam

4 REPLIES 4
vivran22
Community Champion
Community Champion

Hey @Ngars ,

 

You may try the UNPIVOT option in Power Query to transform your table:

 

image.pngUnpivot.gif

 

It will bring all your data in one column:

image.png

 

Hope this helps.

 

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

Hi @vivran22 ,

 

Heres is a more accurate table for what im trying to achieve 

EmployerIndustry SectorIndustry Sector 2Industry Sector 3 Location: town / cityLocation: TPK RegionEmployer size categoryNumber of Cadets contractedDate approved by ISCContract execution dateInterim monitoring Report receivedFinal monitoring report receivedFinancial year
Āhau NZ LimitedInformation media and telecommunications   Te Tai Tokerau 1 10/03/202026/08/20205/10/20202019/20
All Area Scaffolding LimitedConstruction  OtakiTe Tai Hauāuru 3 17/06/2019 29/11/20192018/19
Broadspectrum (New Zealand) LimitedElectricity, gas, water and waste servicesConstruction AucklandNational / multiple50+1530/07/2020   2020/21
Alliance Services LimitedConstruction   Tāmaki Makaurau 2 9/02/2020 20/08/20202019/20

 

So im trying to join the three industry columns to show totals i.e the contruction total would be 3.

 

However, I have visuals and measure that SUM other columns e.g. "Number of Cadets Contracted".

 

By using the UNPOVIT option it would create duplicated rows of each, which would then double the totals of my other measure and visuals. 

 

Sorry I cant seem too attach a pibix file. 

 

 

 

 

 

 

 

Hey @vivran22,

 

I did try and unpivot the columns, the only issue I had was it created duplicate rows, and it creates problems for other visuals and totals I have.

 

Thanks,

 

Sam

vivran22
Community Champion
Community Champion

@Ngars 

 

Can you share more details about the model schema, may be the sample pbix file?

 

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Kudoed Authors