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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Mugeo77
Frequent Visitor

Divide Count of Raw and quantities based on slicer

Hi,

Looking for an help with a formula that help me to have a calculated column based on slicer applied

I have a table like this one

BranchTypeOrderQtyItem
123BAC1074563241649390
123BAC1096041921285893
123BAC1096041941649390
456BAC1121785441285893
123BAC1176027841285893
123BAC1179897251285893
123BAC1179897241649435
456BAC1210162841285893
123BAC1212697041285893
123BAC1212697021649435

 

I have a Measure that give me a distinct count of raws "Order" which is: 7.

If I have a slicer for column "Branch" as "123" the measure is 5

If I have a slicer for column "Branch" as "456" the measure is 2

 

I am looking for a formula  called "ROC" that divide the Qty based on the count of raws in column "Order" as per the slicer applied.

If I want to see "ROC"  based on all data the out put should be as per below where ROC = Qty / Count of raws column Order (7 in this case)

BranchTypeOrderQtyItemROC
123BAC10745632416493900.571429
123BAC10960419212858930.285714
123BAC10960419416493900.571429
456BAC11217854412858930.571429
123BAC11760278412858930.571429
123BAC11798972512858930.714286
123BAC11798972416494350.571429
456BAC12101628412858930.571429
123BAC12126970412858930.571429
123BAC12126970216494350.285714

 

If I want to see the "ROC" for "123" Branch the out put should be as per below where ROC = Qty / Count of raws column Order (5 in this case)

 

BranchTypeOrderQtyItemROC
123BAC10745632416493900.8
123BAC10960419212858930.4
123BAC10960419416493900.8
123BAC11760278412858930.8
123BAC11798972512858931
123BAC11798972416494350.8
123BAC12126970412858930.8
123BAC12126970216494350.4

If I want to see the "ROC" for "456" Branch the output should be as per below where ROC = Qty / Count of raws column Order (2 in this case)

 

BranchTypeOrderQtyItemROC
456BAC11217854412858932
456BAC12101628412858932

 

Anybody can help me?

1 ACCEPTED SOLUTION
Mugeo77
Frequent Visitor

Thanks for your reply. I have combined both and come up with the solution that is working for me:

ROC Version 1 = DIVIDE(
    [Sum QTY]
    ,CALCULATE([Order])
    ,0
   
    )
 
Where I have changed the measure for the distinct order like this
Order = CALCULATE
(DISTINCTCOUNT('Table'[Order]),
ALLEXCEPT('Table','Table'[Branch],'Table'[Type])
 
This formula is working for me

View solution in original post

4 REPLIES 4
Mugeo77
Frequent Visitor

Thanks for your reply. I have combined both and come up with the solution that is working for me:

ROC Version 1 = DIVIDE(
    [Sum QTY]
    ,CALCULATE([Order])
    ,0
   
    )
 
Where I have changed the measure for the distinct order like this
Order = CALCULATE
(DISTINCTCOUNT('Table'[Order]),
ALLEXCEPT('Table','Table'[Branch],'Table'[Type])
 
This formula is working for me

Hi @Mugeo77 

Thank you for the update. If you have any more questions, please let us know and we’ll be happy to help.

Regards,

Microsoft Fabric Community Support Team

Praful_Potphode
Impactful Individual
Impactful Individual

Hi @Mugeo77 

 

Please try below:

ROC Version 1 = DIVIDE(
    [Total Quantity]
    ,CALCULATE([#Orders],ALLEXCEPT('Table','Table'[Branch]))
    ,0
    
    )

you can download PBIX from below link.

Sample PBIX

 

Please give Kudos or mark it as solution once confirmed.

 

Thanks and Regards,

Praful

Ahmed-Elfeel
Solution Specialist
Solution Specialist

Hi @Mugeo77,

I hope you are doing well today ☺️❤️

 

So basically to create a dynamic ROC calculation that responds to slicer selections you will need to create a measure (not a calculated column) in Power BI.

 

Note: Calculated columns are static and will not respond to slicers whereas measures dynamically adjust based on filters

 

So try this basic DAX measure :

ROC = 
DIVIDE(
    SUM('YourTable'[Qty]),
    DISTINCTCOUNT('YourTable'[Order]),
    0
)
  • This measure works dynamically with any slicer/filter applied to your report

  • If you need to use this value in further calculations make sure you reference it as a measure (not a column)
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.