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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors