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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
erpbi
New Member

How to use distinct count from a slicer filtered table in a calculation applied to each row

Hello,

 

I have a table that contains various products, all identified by a unique Product ID.  This table can be filtered using slicers, by either Product ID, or Product Description.  However, some items may have the same description, although the Product ID remains unique.  I have costs for each product showing in each row of the table, and I need to add a formula to show a discounted price if more than 1 unique Product ID is contained within the table (based on the filtered slicer selection).

 

For example, if someone uses the slicers to filter down the table to 1 product, they will see the product attributes in separate columns, followed by a column for the full price of that item.  If they select multiple products via the slicers, then a set % discount needs to be applied to each row, and shown in its own column along with a grand total.

 

I've been able to use a measure to add a column showing the discount % to apply as follows:

DiscountPct = CALCULATE(DISTINCTCOUNT('ProductPricing'[ProductId]),ALLSELECTED('ProductPricing'))
 
Now ideally, I'd be able to create a new column to multiply this DiscountPct measure by each row, but when I do that, the calculated column doesn't update with each selection within the slicers.
 
Any suggestions on the best way to accomplish this?  Here are 2 examples of tables to show what the expected behavior should be, the Discounted Price column is the one I'm unable to get working:
 
1 unique product ID value selected by the slicers:
Product IDProduct DescriptionOriginal PriceMultiple Part DiscountDiscounted Price
P100Part 100$100.000%$100.00
Total: $100.000%$100.00

 

More than 1 unique Product ID selected:

Product IDProduct DescriptionOriginal PriceMultiple Part DiscountDiscounted Price
P100Spare Part$100.0010%$90.00
P101Another Spare Part$125.0010%$112.50
P102Some Other Spare Part$50.0010%$45.00
P103Spare Part$75.0010%$67.50
Total: $350.0010%$315.00

 

1 ACCEPTED SOLUTION

Thanks for the feedback, I hadn't thought to aggregate the price for some reason.  However, I did try that, and it made all the line-level calculations correct, but was still using the lowest price when calculating the total row, which doesn't work for this usage.  What I ended up doing is using a SUM instead of the MIN you included below, and that took care of both the line-level details as well as the grand totals.

 

Thanks for the help!

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

=MIN('ProductPricing'[Original Price])*(1-[DiscountPct])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for the feedback, I hadn't thought to aggregate the price for some reason.  However, I did try that, and it made all the line-level calculations correct, but was still using the lowest price when calculating the total row, which doesn't work for this usage.  What I ended up doing is using a SUM instead of the MIN you included below, and that took care of both the line-level details as well as the grand totals.

 

Thanks for the help!

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.