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

Next 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

Reply
Jos13
Helper III
Helper III

Distribute sales to filtered values

Hi All,

I have the following table.

cust_sales.png

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 

1 ACCEPTED 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

 

DIS1.jpg

 

DIS2.jpg

 

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

 

DIS3.jpg

 

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.

View solution in original post

5 REPLIES 5
v-zhenbw-msft
Community Support
Community Support

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?

 

DIS1.jpg

 

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'))

 

DIS2.jpg

 

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,

filter.png

 

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.

old.png

new.png

 

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,

 

DIS3.jpg

 

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.

scr1.png

 

 

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

 

DIS1.jpg

 

DIS2.jpg

 

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

 

DIS3.jpg

 

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.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.