Forum Discussion
Display sales inside a fix range
Hi folks,
I`m kind new to Dax and need help for some specific requirement.
I have a measure that checks the total sales grouped by client inside a range (contained in a table called Range) and I have a slicer (with only one selection - radio button) that allows user to filter data sales on specific range. my measure gives the right result when it comes to only one selection (Please see below).
Now, the users want to be able to filter on two or more ranges and I don't know how to make power bi compares sales for each range selected
let me give you more context.
First, here's the ranges we have :
And the measure created for only one selection is :
TotalSalesRange =
Var Virtualtable = Summarize( Sales, Sales[clientid],"sales",sum(Sales[Amount]))
Var MinRangeSelected = SelectedValue (Range[min])
Var MaxRangeSelected = SelectedValue (Range[max])
Return
SUMX (
Filter( Virtualtable, [sales]>= MinRangeSelected && [sales]< MaxRangeSelected)
[sales]
)
Does anyone know how I can created the measure that will consider all ranges selected ?
Thanks for your help.
RedGC
Hi, Anonymous
Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.
I tried to create a sample that suits your request.
All measures are in the sample pbix file.
https://www.dropbox.com/s/5nb9e89jsc20079/red.pbix?dl=0
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: https://www.linkedin.com/in/jihwankim1975/
17 Replies
- Ashish_MathurSuper User
Hi,
See if this helps - Dynamic segmentation.
- Jihwan_KimSuper User
Hi, Anonymous
Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.
I tried to create a sample that suits your request.
All measures are in the sample pbix file.
https://www.dropbox.com/s/5nb9e89jsc20079/red.pbix?dl=0
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: https://www.linkedin.com/in/jihwankim1975/- Syndicate_AdminAdministrator
Hello. How did you manage to solve it? I have the same problem. I need to do a customer counter in a sales range every month of the year. I mean, I need something like this.
I have this information:
And I need to build something like this:
It's similar to your solution. please help me? as you built it. Thank you.
- Jihwan_KimSuper User
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
Clients count: = VAR _minrange = MIN ( Range[Min] ) VAR _maxrange = MAX ( Range[Max] ) VAR _salestable = ADDCOLUMNS ( SUMMARIZE ( Sales, Client[Client] ), "@sales", CALCULATE ( SUM ( Sales[Sales] ) ) ) VAR _rangetable_clientlist = SUMMARIZE ( FILTER ( _salestable, [@sales] > _minrange && [@sales] <= _maxrange ), Client[Client] ) RETURN IF ( HASONEVALUE ( 'Month'[Month] ), COUNTROWS ( _rangetable_clientlist ) )
- AnonymousNot applicable
Hi,
Thanks Jihwan_Kim and Ashish_Mathur for your reply.
Sorry guys, but I just noticed that I missed a detail in the description of my message. Actually, what I'm looking to have is the total sales of the sales that are in the specified ranges. for example, let's take the following example.
I have sales for 2020 for two customers:and We have the following range as a Slicer:
$0 - 100K
$100K - $200K.
$200K - $300K.
$300K - $400K.
$400K - $500K.
$500K - $600K.
Now, My question is how can I get the total sales of those sales that are between $100K - $200K and the sales between $300K - $400K ( assuming that users have selected $100K - $200K and $300K - $400K in the Slicer)
In Excel, I would filtered first my data by $100K - $200K and $300K - $400K and then, calculate the total sales which give me the followin result :I hope this example helps you well understant my case.
Thanks for your help.
RedGC- Jihwan_KimSuper User
Hi, Anonymous
I tried to add one more dimension (product 1 and product 2) in order to make it similar to your sample case.
Please check the link down below.
https://www.dropbox.com/s/6b320ns8hcv8ujv/red2.pbix?dl=0
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: https://www.linkedin.com/in/jihwankim1975/- AnonymousNot applicable
Hi Jihwan_Kim,
Will send you the file asap.
thanks alot for your help, I really appreciate it.
- Ashish_MathurSuper User
Hi,
Share the link from where i can download your Excel file.
- AnonymousNot applicable
Hi Ashish_Mathur ,
here is the link :
https://www.dropbox.com/scl/fi/4q7ci5jcc4oksviuxkcop/DemoData_Ashish.xlsx?dl=0&rlkey=1ao56oenwsocwhiigyfxttg50Thanks,
RedGC
- AnonymousNot applicable
Hi Jihwan_Kim ,
Thanks alot for your reply and effort.
your solution works good when we want to go through all groups, but my requirement is the user has to select the group(s)/range(s) in a slicer and based on it the calculation will happen for the total sales.I tried used ALLSELECT(Group[min]) and because it returns a table, it can be used in your the formula.
Thanks,RedGC
- AnonymousNot applicable
I meant ALLSELECTED(Group[min])
- AnonymousNot applicable
Ashish_Mathur , any idea ?
Thanks for your help.RedGC
- v-cazheng-msftCommunity Support
Hi Anonymous
I'm not sure what field you are using as the slicer, but you can try a Measure as following.
TotalSalesRange = CALCULATE(SUM(Sales[Sales]),ALLSELECTED(Range[range]))The result looks like this:
For more details, you can refer the attached pbix file.
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.