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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Nahel88
Frequent Visitor

Writing a Function

Hello, 

I am new at Power BI and i want to create a report so, Im still new with syntax the point is:
I have a 2 columns one of them is Product and the other one is the Quantity , so i need to find out the Sum of Quantites for a specific product, i did that in Qlik Sense the and syntax was like this :
Num(sum({$ <Product={Cores}>} Quantity),'#.##0,00',',','.')

how to convert it to Power BI

Thnx

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Nahel88 on a more general note, while I do not think that you need a formula in this case, as @ankitpatira says, I assume that at some point you will. The function reference for DAX is here:

 

https://msdn.microsoft.com/en-us/library/ee634396.aspx

 

The function reference for Power Query "M" is here:

https://msdn.microsoft.com/en-us/library/mt211003.aspx

 

In DAX, your formula below would be something like this in a measure:

 

Sum of Quantities = SUM([Quantities])

But, as @ankitpatira states the visualizations sort of do that automagically.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Nahel88 on a more general note, while I do not think that you need a formula in this case, as @ankitpatira says, I assume that at some point you will. The function reference for DAX is here:

 

https://msdn.microsoft.com/en-us/library/ee634396.aspx

 

The function reference for Power Query "M" is here:

https://msdn.microsoft.com/en-us/library/mt211003.aspx

 

In DAX, your formula below would be something like this in a measure:

 

Sum of Quantities = SUM([Quantities])

But, as @ankitpatira states the visualizations sort of do that automagically.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
ankitpatira
Community Champion
Community Champion

@Nahel88 In power bi desktop you don't need to write code to be able to do that. You can choose any visual say for example column chart and you need to drop Quantity field in Value area and Product field in Axis area. This will automatically give you sum of quantities by product. For a specific product you can use filter or slicer. You also have option to specify count, sum or other aggregations for Quantiy column.

well in some how i did it :

Cores = CALCULATE(SUM('test'[Quantity]);'test'[Product]= "Cores")

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.