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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
xuexi1890
Helper I
Helper I

distinctcount of product with lowest price (all) for each distributor

Hello,

below is my dataset (as an example), I want to calculate how many products with lowest price sold of each distributor, same as SummaryTable1, meanwhile having another SummaryTable2 to show me what are the cases.
Untitled.png
thank you so much for helping me out!

my initial attempt was to create an array of numbers (each product code with min price) and then use this array as a criterion to filter in my dataset when the product is the same and the price is equal to the min price, but of course failed. I don't quite understand the concept of PBI when the array is relevant to a certain column (same product).

Sincerely,
Nate

1 ACCEPTED SOLUTION

@v-chuncz-msft 

thanks Sam. i tried myself and succeeded.

 

i put it here if anyone is interested.

 

MinPrice =
VAR _Quarter=ALLSELECTED(Table1[Quarter])
VAR _Month=ALLSELECTED(Table1[Month])
Return
CALCULATE(
min(Table1[price]),
ALL(Table1),
values(Table1[Product]),
Table1[Quarter] IN _Quarter,
Table1[Month] IN _Month
)
 
DistinctCount of CP =
VAR _Quarter=ALLSELECTED(Table1[Quarter])
VAR _Month=ALLSELECTED(Table1[Month])
Return
CALCULATE(
DISTINCTCOUNT(Table1[Product]),
FILTER(ALLEXCEPT(Table1,Table1[Quarter],Table1[Month]),Table1[price]=[MinPrice]),
VALUES(Table1[Distributor]),
Values(Table1[Product]),
Table1[Quarter] IN _Quarter)

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@xuexi1890 

 

You may add a calculated column first.

Column =
IF (
    'Table'[Price]
        = MINX (
            FILTER ( 'Table', 'Table'[Product] = EARLIER ( 'Table'[Product] ) ),
            'Table'[Price]
        ),
    1
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft 

thanks Sam. i tried myself and succeeded.

 

i put it here if anyone is interested.

 

MinPrice =
VAR _Quarter=ALLSELECTED(Table1[Quarter])
VAR _Month=ALLSELECTED(Table1[Month])
Return
CALCULATE(
min(Table1[price]),
ALL(Table1),
values(Table1[Product]),
Table1[Quarter] IN _Quarter,
Table1[Month] IN _Month
)
 
DistinctCount of CP =
VAR _Quarter=ALLSELECTED(Table1[Quarter])
VAR _Month=ALLSELECTED(Table1[Month])
Return
CALCULATE(
DISTINCTCOUNT(Table1[Product]),
FILTER(ALLEXCEPT(Table1,Table1[Quarter],Table1[Month]),Table1[price]=[MinPrice]),
VALUES(Table1[Distributor]),
Values(Table1[Product]),
Table1[Quarter] IN _Quarter)

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.