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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

@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.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@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.


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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