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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.

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
Helper I

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)
2 REPLIES 2
Community Support

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.
Helper I

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

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors