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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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