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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
b2wise
Helper III
Helper III

Track Lowest Priced Items Over Time

Hi all,

 

I have an item header table and a price history table along with a date table. I am trying to count distinct items in which Daisy (my company) had the lowest price vs the competition (Denways and Carolina Dreaming) and show that over time.

 

These are my tables:

 

Item Headers

ItemDescription
6Seeds
7Flowers
8Soil

 

Price History

DateItemVendorQty Break Price 
5/8/20228Daisy1                                     355.00
5/8/20228Carolina Dreaming1                                     315.00
5/8/20228Denways1                                     328.00
5/8/20226Daisy1                                     228.00
5/8/20226Carolina Dreaming1                                     389.00
5/8/20226Denways1                                     107.00
5/8/20227Daisy1                                        97.00
5/8/20227Carolina Dreaming1                                     347.00
5/8/20227Denways1                                     120.00
5/9/20227Daisy1                                     377.00
5/9/20227Carolina Dreaming1                                     223.00
5/9/20227Denways1                                     187.00
5/9/20226Daisy1                                     337.00
5/9/20226Carolina Dreaming1                                     255.00
5/9/20226Denways1                                     218.00
5/9/20228Daisy1                                     199.00
5/9/20228Carolina Dreaming1                                     371.00
5/9/20228Denways1                                     356.00
5/10/20226Daisy1                                     366.00
5/10/20226Carolina Dreaming1                                     299.00
5/10/20226Denways1                                        81.00
5/10/20227Daisy1                                     123.00
5/10/20227Carolina Dreaming1                                          5.00
5/10/20227Denways1                                        63.00
5/10/20228Daisy1                                     229.00
5/10/20228Carolina Dreaming1                                     119.00
5/10/20228Denways1                                     258.00

 

This is the result I am trying to get:

 

DateDaisy Items ListedDaisy Winning Items
5/8/202230
5/9/202230
5/10/202231

 

Looks simple but I'm not sure how to do this in DAX.

 

Thanks in advance!

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@b2wise,

 

Try these measures. In the measure Daisy Winning Items, I get different results from your expected result. In the sample data for 5/10/2022, Daisy doesn't have the lowest price for any Item but your expected result shows 1.

 

Daisy Items Listed =
CALCULATE (
    DISTINCTCOUNT ( 'Price History'[Item] ),
    'Price History'[Vendor] = "Daisy"
)
Daisy Winning Items = 
VAR vTable =
    ADDCOLUMNS (
        SUMMARIZE (
            'Price History',
            DimDate[Date],
            'Price History'[Item],
            'Price History'[Vendor],
            'Price History'[Price]
        ),
        // calculate the min price for each combination of Date and Item
        "@MinPrice",
            CALCULATE (
                MIN ( 'Price History'[Price] ),
                ALLEXCEPT ( 'Price History', DimDate[Date], 'Price History'[Item] )
            )
    )
VAR vResult =
    SUMX (
        FILTER ( vTable, 'Price History'[Vendor] = "Daisy" ),
        IF ( 'Price History'[Price] = [@MinPrice], 1 )
    )
RETURN
    vResult

 

DataInsights_0-1653575902257.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@b2wise,

 

Try these measures. In the measure Daisy Winning Items, I get different results from your expected result. In the sample data for 5/10/2022, Daisy doesn't have the lowest price for any Item but your expected result shows 1.

 

Daisy Items Listed =
CALCULATE (
    DISTINCTCOUNT ( 'Price History'[Item] ),
    'Price History'[Vendor] = "Daisy"
)
Daisy Winning Items = 
VAR vTable =
    ADDCOLUMNS (
        SUMMARIZE (
            'Price History',
            DimDate[Date],
            'Price History'[Item],
            'Price History'[Vendor],
            'Price History'[Price]
        ),
        // calculate the min price for each combination of Date and Item
        "@MinPrice",
            CALCULATE (
                MIN ( 'Price History'[Price] ),
                ALLEXCEPT ( 'Price History', DimDate[Date], 'Price History'[Item] )
            )
    )
VAR vResult =
    SUMX (
        FILTER ( vTable, 'Price History'[Vendor] = "Daisy" ),
        IF ( 'Price History'[Price] = [@MinPrice], 1 )
    )
RETURN
    vResult

 

DataInsights_0-1653575902257.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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