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
Michael_nik
Regular Visitor

Making a pivot table

Hi everyone!

 

I'm new in power bi, but I have a strong basis in Pyton. I was given a simple task to make a table from sample one which is given in Power BI by default. So the task is to calculate the Product with lowest Sale Price and corresponding to this Product and Gross Sales for each month.

 

It looks easy to do it in python by making a groupby func with using min, but I have no idea how to add the corresponding product to it in PowerBI, because there can be more than one product wich has the lowest price = 7.

 

Hope I will able to get the answer in 2 days!

 

P.S. I already made a auxiliary table called Calendar, so now there are two tables: financials and Calendar that can be used to answer the question.

1 ACCEPTED SOLUTION

Use this measure:

Gross Sales by min Sale Price =
VAR _minPrice =
    MIN ( financials[Sale Price] )
VAR _MinPriceAll =
    CALCULATE ( MIN ( financials[Sale Price] ), ALL ( 'Product Table' ) )
RETURN
    CALCULATE (
        SUM ( financials[Gross Sales] ),
        FILTER ( 'Product Table', _minPrice = _MinPriceAll )
    )

mi sale price.png





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

7 REPLIES 7
PaulDBrown
Community Champion
Community Champion

Well it depends on what the definition of lowest price is. If it is the price resulting from dividing sales by the number of units sold, then...

I'm working with this model structure:

model.pngTo get the sales price by product for since the beginning of time:

 

Price by Product all years =
CALCULATE (
    DIVIDE ( SUM ( financials[ Sales] ), SUM ( financials[Units Sold] ) ),
    ALL ( 'Dates Table' )
)

 

and the lowest for all products

 

Lowest Sales Price all products = 
MINX(ALL('Product Table'[dProduct]), [Price by Product all years])

 

and finally the sales by month for the lowest selling price product 

 

Gross Sales for lowest Price Porduct =
SUMX (
    'Dates Table',
    CALCULATE (
        SUM ( financials[Gross Sales] ),
        FILTER (
            'Product Table',
            [Price by Product all years] = [Lowest Sales Price all products]
        )
    )
)

 

all years.png

If you want to see the excercise by year...

 

Low price by year =
CALCULATE (
    DIVIDE ( SUM ( financials[ Sales] ), SUM ( financials[Units Sold] ) ),
    ALL ( 'Dates Table'[Month] )
)
Lowest price by Year = 
MINX(ALL('Product Table'[dProduct]), [Low price by year])
Gross Sales for lowest Price Porduct by year =
SUMX (
    VALUES ( 'Dates Table'[Month] ),
    CALCULATE (
        SUM ( financials[Gross Sales] ),
        FILTER ( 'Product Table', [Low price by year] = [Lowest price by Year] )
    )
)

 

by year.png

 

Sample PBIX file attached

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






I was expecting to get something like this, but to have table that contains only price = 7 you need to add filter which is irrational and affects another data on the wallpaper 😞

I can also take first N rows that have 7 in the second column but it's shady too...

 

Michael_nik_0-1665265535702.png

 

Use this measure:

Gross Sales by min Sale Price =
VAR _minPrice =
    MIN ( financials[Sale Price] )
VAR _MinPriceAll =
    CALCULATE ( MIN ( financials[Sale Price] ), ALL ( 'Product Table' ) )
RETURN
    CALCULATE (
        SUM ( financials[Gross Sales] ),
        FILTER ( 'Product Table', _minPrice = _MinPriceAll )
    )

mi sale price.png





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






You are amazing! That's exactly what I wanted!

Oh wow! That's a really great job, but actually I hoped if you knew how to build something like this:
Month  ------- Min price ------- Product name ------- Gross price

Janury  -------               7 -------      Montana    -------   10k

Janury  -------               7 -------      Paseo         -------   20k

February -----               7 -------      VTT            -------   10k

March  -------               7 -------      Montana    -------   10k

and etc.

 

 

All numbers except min price are random. So the idea was to get one or more data from each month by product. I mean I need a table where there are 12 months and next column contain minimum price per each month (Price = Sale price column). And then comes the name of all products that has the same price (with gross sales after it - but it's easy, just calculate Sum of...) Hope you got me🥺

PaulDBrown
Community Champion
Community Champion

Can you share sample data please?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






To get the data, you just need to open PowerBI desktop, then choose sample data!

Hope you know how to help me, because I no longer have the strength to accomplish this task

Michael_nik_0-1665249412258.pngMichael_nik_1-1665249427853.png

Michael_nik_2-1665249441306.png

 

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.

Top Solution Authors