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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
simmi21
Frequent Visitor

Calculate Sum by applying Group By and filetr in combination

Dear Team, 

 

 

I want to calculate a sum of column by selecting the earliest date in a group of multiple fields.

Because the values are redundant on the weekly level, while creating a sum function it is aggregating all the values.

 

Target is to get for M0 : 135672+289857 and same for other M1 and M2

 

 

Here is the example:

 

simmi21_0-1605611991879.png

 

 

Any suggetion what might be helpful ?

5 REPLIES 5
amitchandak
Super User
Super User

@simmi21 , Try Measure

sumx(summarize(Table,Table[Column1], Table[Column2], Table[Column6]),[Column6])

or

calculate(firstnonblankvalue(Table[column1], sum(Table[column6])), allexcept(Table, table[column2]))

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks Amit, it helped a bit but not completly.

The sumx(summarize(Table,Table[Column1], Table[Column2], Table[Column6]),[Column6]) works in some cases and in some cases giving wrong results.

 

 

Is there a way to get firstnonblankvalue by using combination of two columns ? 

 

In my above sample data set 

Combination of column 1 & Column 2 should return a sum of distinct value from column 6.

 

In SQL term it should be -

select sum(distinct(Column6)) , Column1, Column2  group by column1 & column 2

Fowmy
Super User
Super User

@simmi21 

Are you looking for the earliest date 1st or 3rd column and is the earliest in a month?

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@simmi21 , Not very clear with give data

You can try measures like

 


firstnonblankvalue(Table[Date], sum(Table[Value]))

or

calculate(firstnonblankvalue(Table[Date], sum(Table[Value])), allexcept(Table, table[group]))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I want to do the sum of Column 6 in my example for the first values only in a combination of Column 1 & 2.   

 

AS Coulmn 1 is a slicer variable and it can have more than one date field. so for a combination of dates from column 1 , Column 2  (M0, M1, M2) should refelect the sum of unique values for a combination of Column 1 & 2  

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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