Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi All,
I have the following table.
Here the total sales by all customers is 32. I will have a dropdown, in that only 3 customers(Customer1, 2 & 3) are included(Customer4 & 5 are excluded). With these 3 customers in the dropdown, I want to show the sales as 32 by distributing sales of customer 4 & 5 among other 3 customers. Is there any way to achieve this ? I don't know how to figure out this problem. Kindly help me on this.
Thanks,
Jos
Solved! Go to Solution.
Hi @Jos13 ,
The measure Total doesnโt summarize, it is based on the calculation logic of each row.
If you want to get the correct total, we suggest to create a calculate column like this.
Column =
var _C4_C5 = CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),'Table'[Customer] in {"Customer 4","Customer 5"} && 'Table'[Date]=EARLIER('Table'[Date])))
var _avg = _C4_C5 / 3
return
'Table'[Sales] + _avg
But if you want to show the Total sales of each customer using a bar chart, you can try this Measure.
Measure =
VAR _Total123 =
CALCULATE (
SUM ( 'Table'[Sales] ),
ALLSELECTED ( 'Table' ) )
VAR _Total45 =
CALCULATE (
SUM ( 'Table'[Sales] ),
ALL ( 'Table' )
) -_Total123
VAR _count =
CALCULATE ( DISTINCTCOUNT ( 'Table'[Customer] ), ALLSELECTED('Table') )
VAR _sum_sales =
SUM ( 'Table'[Sales] )
RETURN
_Total45 / _count + _sum_sales
The measure only displays the correct value in the current context.
If you have any question, please kindly ask here and we will try to resolve it.
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Jos13 ,
Sorry for that we have a little confuse about your issue.
What is a dropdown, is it a Slicer? Or is it a Table Visual?
Do you want to show the Total as 32 when select Customer1, Customer2, Customer3 in Slicer?
If yes, you can use ALL function to create a measure, then put it to a card visual.
Measure = CALCULATE(SUM('Table'[Sales]),ALL('Table'))
If it doesnโt meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-zhenbw-msft ,
The filter I was talking about will look like this,
On 1st June 2020, combined sale of customers 4 & 5 is 3. I want to distribute this 3 to other 3 customers equally so that they get 1 sale each.
Thanks,
Jos
Hi @Jos13 ,
We can create a measure to meet your requirement.
Total Sales minus the selected Sales to get the Sales that need to be allocated.
Measure =
VAR _Total123 =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
)
VAR _Total45 =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
) - _Total123
VAR _count =
CALCULATE ( DISTINCTCOUNT ( 'Table'[Customer] ), ALLSELECTED ( 'Table' ) )
VAR _sum_sales =
SUM ( 'Table'[Sales] )
RETURN
DIVIDE ( _Total45, _count ) + _sum_sales
The result like this,
If you have any question, please kindly ask here and we will try to resolve it.
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-zhenbw-msft ,
Could you please tell why total is 23 in table ? It should be 32. The sales by customers 1,2 & 3 adding to 27 in bar chart. This should also be 32. Please help.
Regards,
Jos
Hi @Jos13 ,
The measure Total doesnโt summarize, it is based on the calculation logic of each row.
If you want to get the correct total, we suggest to create a calculate column like this.
Column =
var _C4_C5 = CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),'Table'[Customer] in {"Customer 4","Customer 5"} && 'Table'[Date]=EARLIER('Table'[Date])))
var _avg = _C4_C5 / 3
return
'Table'[Sales] + _avg
But if you want to show the Total sales of each customer using a bar chart, you can try this Measure.
Measure =
VAR _Total123 =
CALCULATE (
SUM ( 'Table'[Sales] ),
ALLSELECTED ( 'Table' ) )
VAR _Total45 =
CALCULATE (
SUM ( 'Table'[Sales] ),
ALL ( 'Table' )
) -_Total123
VAR _count =
CALCULATE ( DISTINCTCOUNT ( 'Table'[Customer] ), ALLSELECTED('Table') )
VAR _sum_sales =
SUM ( 'Table'[Sales] )
RETURN
_Total45 / _count + _sum_sales
The measure only displays the correct value in the current context.
If you have any question, please kindly ask here and we will try to resolve it.
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |