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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Paritäa
Frequent Visitor

IF statement for each row

Hi everyone!

 

So I have been working on this problem the whole day and tried so many different ways to solve it but it just won't work!

I have a table, each row is a new address which has a value.

Because there are over 3000 rows, I want to summarize these values in ranges. I don't care about the addresses, the focus lies on how big each range is.

The ranges should be in steps of 10.

Here is the Excel-File: https://1drv.ms/x/s!Ao7ZiNWuV2I6gcRksSZgh2sOG-12Zg?e=ZoU265 

 

Here an example of what I want at the end:

For Row "0-9.9": Sum all Values between 0 to <10

For Row "10-19.9": Sum all Values between 10 to <20

For Row "20-29.9": Sum all Values between 20 to <30

...

For Row "+50": Sum all Values >=50

 

PS: Is it possible to upload the file? Because I won't keep it in my OneDrive forever and it would be sad for future HelpSeekers, if they can't access it anymore...

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Paritäa ,

 

According to your description, here are my steps you can follow as a solution.

(1) Enter data.

vtangjiemsft_0-1669098775231.png

(2) We can create a calculated column.

Sum of value =
SWITCH(
    [Row name],
    "0-9.9",SUMX(FILTER('Table (2)',[Value]>=0&&[Value]<10),[Value]),
    "10-19.9",SUMX(FILTER('Table (2)',[Value]>=10&&[Value]<20),[Value]),
    "20-29.9",SUMX(FILTER('Table (2)',[Value]>=20&&[Value]<30),[Value]),
    "30-39.9",SUMX(FILTER('Table (2)',[Value]>=30&&[Value]<40),[Value]),
    "40-49.9",SUMX(FILTER('Table (2)',[Value]>=40&&[Value]<50),[Value]),
    "+50",SUMX(FILTER('Table (2)',[Value]>50),[Value]))

(3) Then the result is as follows.

vtangjiemsft_1-1669098814784.png

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

8 REPLIES 8
Paritäa
Frequent Visitor

Because I don't know how to insert the ëxample file, I'll just put the table in here:

AddressValue
A2.5
B2.8
C2.4
D2.4
E2.5
F2.6
G1.2
H2.7
I3
J2.8
K1.8
L5.2
M3.4
N3
O1
P2.5
Q8.4
R1.5
S14.3
T15.7
U1.7
V6.6
W12.8
X22
Y17.4
Z10
AA20.4
AB80
AC15
AD1.7
AE1.7
AF50
AG6
AH12
AI1.2
AJ22
AK6.7
AL1
AM12
AN21
AO25.5
AP49.5
AQ25.5
AR50
AS34.5
AT80
AU30
AV10.2
AW15
AX12
AY4.8
AZ26.5
Anonymous
Not applicable

Hi @Paritäa ,

 

According to your description, here are my steps you can follow as a solution.

(1) Enter data.

vtangjiemsft_0-1669098775231.png

(2) We can create a calculated column.

Sum of value =
SWITCH(
    [Row name],
    "0-9.9",SUMX(FILTER('Table (2)',[Value]>=0&&[Value]<10),[Value]),
    "10-19.9",SUMX(FILTER('Table (2)',[Value]>=10&&[Value]<20),[Value]),
    "20-29.9",SUMX(FILTER('Table (2)',[Value]>=20&&[Value]<30),[Value]),
    "30-39.9",SUMX(FILTER('Table (2)',[Value]>=30&&[Value]<40),[Value]),
    "40-49.9",SUMX(FILTER('Table (2)',[Value]>=40&&[Value]<50),[Value]),
    "+50",SUMX(FILTER('Table (2)',[Value]>50),[Value]))

(3) Then the result is as follows.

vtangjiemsft_1-1669098814784.png

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

So I was able to solve the first problem, it was a formating problem. But I just can't get around the last problem...

Found the last problem! Forgot to put a sign in the name, so it didn't recognize where to put it in the table.

Thank you so much for your detailed answer!

Awesome! Finally some results! I do now face two problems:

1. Two results which are weird, as it produces values with 11 decimal digits:
0-9.9     = 302.49999999999999
20-29.9 = 310.30000000000001
How can it result in these many decimal digits if all my values only have 1 decimal digit?

2. The last range +50, does not produce a result. The cell stays empty, even though I do have two values which are higher than 50...

ryan_mayu
Super User
Super User

@Paritäa 

1. create an index column in PQ

2. use DAX to create a group column

group = if('Table'[Index]<50, int('Table'[Index]/10)+1,6)

3. use DAX to create a column to check if the value is in the scope

Column = 
if('Table'[Value]>=('Table'[group]-1)*10 &&'Table'[Value]<('Table'[group]+1)*10,"Yes")

4. create a measure

Measure = CALCULATE(sum('Table'[Value]),'Table'[Column]="Yes")

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I'd also like to try your version but I don't even know how to enter Power Query and therefore add index columns. I tried with online tutorials but the all have PQ already open.
My only tab options in the Home tab is:

Parita_0-1669109049522.png

Sorry, it's German but as you can see, I only have the option to add a "basic" column but there are no options to choose what type of columns to add.

i think I misunderstood your request. 

my solution may not fit your situation. 

Let's see @Anonymous 's solution 

1. you can change the column type

1.PNG

2. it should display values

pls see the attachment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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