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
camilocorralesg
Advocate I
Advocate I

How to sum 1 every 5 new customers in a custom column

Hi everybody, I need to add a custom column where I count 1 every 5 new customers in the "Clientes Nuevos" column. 

For example, with this data

camilocorralesg_0-1658287166749.png

the expected output would be

Cada 5 clientes
1
1
7
1
3
2
3
1
2
1
1

 

what kind of function/logic can i use to calculate this on power query? Thanks in advance

1 ACCEPTED SOLUTION

Vijay, i already answered myself in this last comment, i just needed to use the Number.RoundDown function to get my expected result, anyway, thank you for your answer and time!

View solution in original post

4 REPLIES 4
Vijay_A_Verma
Super User
Super User

Looks like there is some other column driving your output. Can you also post required column and also what is the business logic for calculating this?

Hi Vijay, there's no other required column, i just need to figure out a way to Divide the "clientes nuevos" number by 5 and round the result down. For example, if i have 9 then 9/5 = 1.8 but my expected output need to be only 1, another example could be 34/5 = 6.8, but i need to round down that number to 6. Thank you for your answer

Vijay, i already answered myself in this last comment, i just needed to use the Number.RoundDown function to get my expected result, anyway, thank you for your answer and time!

Use below formula in a custom column

= Number.IntegerDivide([Clientes nuevos],5)

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMleK1YGRxpZgyhRMGppBKCMIZQGmoGLGSOqAZCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Clientes nuevos" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Clientes nuevos", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Cada 5 clientes", each Number.IntegerDivide([Clientes nuevos],5), type number)
in
    #"Added Custom"

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.

Top Solution Authors
Top Kudoed Authors