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

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
Europe Fabric Conference

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 Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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