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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Help with DAX formula into loop

Hello all,

I have a question about my power query DAX formula. Below is my SWITCH and I want to put this in a loop.
I want to constantly increase my loop by 2.5 because I have a lot of different values from 0 to 1000.

 

Bedrag =
SWITCH (
TRUE(),
Order[Amount Order] >= 0 && Order[Amount Order] < 5 , "< 5",
Order[Amount Order] >= 5.1 && Order[Amount Order] <= 7.5, "5 - 7.5",
Order[Amount Order] >= 7.51 && Order[Amount Order] <= 10, "7.51 - 10",
Order[Amount Order] >= 10.01 && Order[Amount Order] <= 12.5, "10.01 - 12.5",
Order[Amount Order] >= 12.51 && Order[Amount Order] <= 15, "12.51 - 15",Blank())
 
I can't figure it out myself, can someone help me.
 
Thank You!
 
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I am not sure if I understood your question correctly, but I suggest having a grouping table like below.

Please check the below picture and the sample pbix file's link down below.

I tried to create a sample pbix file based on the explanation. And the below type of grouping table is easy to create in excel and it can be imported into Power BI easily.

 

Picture1.png

 

Qty Total by Group =
SUMX (
FILTER (
VALUES ( Sales[Date] ),
COUNTROWS (
FILTER (
'Grouping',
[Qty Total] > 'Grouping'[Min]
&& [Qty Total] <= 'Grouping'[Max]
)
) > 0
),
[Qty Total]
)
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I am not sure if I understood your question correctly, but I suggest having a grouping table like below.

Please check the below picture and the sample pbix file's link down below.

I tried to create a sample pbix file based on the explanation. And the below type of grouping table is easy to create in excel and it can be imported into Power BI easily.

 

Picture1.png

 

Qty Total by Group =
SUMX (
FILTER (
VALUES ( Sales[Date] ),
COUNTROWS (
FILTER (
'Grouping',
[Qty Total] > 'Grouping'[Min]
&& [Qty Total] <= 'Grouping'[Max]
)
) > 0
),
[Qty Total]
)
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Hi Jihwan, 

 

I see that my analysis is not quite consistent with what you sent, but we are almost there. 

The data I have:
I have orders with a total order amount. Now they want to have the number of orders that fall into the categories 0 - 2.50, 2.51 - 5, et cetera. So what I have to do is count the number of orders which is between the amounts 0 - 2.50 et cetera.
Your answer is very similar to my question, but I get to see the sum of the total amount. I actually need the sum of all the orders in the different categories.

 

I don't quite understand the second table you sent me.

I see in the right table that there is only 1 order with a qty of 5 and your analysis there are 5.
I see there is only 1 qty of 12 and your analysis there are 12.
between 12.5 and 15 I only see 2 and your analysis there are 28.

 

Do you understand what I mean?

 

Thans for you answer!!

 

Hi, @Anonymous 

If it is OK with you, please share your sample pbix file's link here, together with the desired outcome that you want to see. Then I can try to look into it to come up with a more accurate measure. 

Thanks.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Hi,

Thank you for sharing.

Sorry that I quite do not understand.

I see that 0 <= <=5 : count of orders => 36

but your desired outcome seems to show a different number.

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Thanks a lot, That's exactly what I want!! 😀

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.