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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Faustyna
Frequent Visitor

Counting unique number of products that were on offer in the past and are now

Hi!

 

I need to count unique number of products that were in the assortment, for example, in January and are now. I can't do normally: calculate(DISTINCTCOUNT(Assort[ProductId]),month(Assort[AssortDate])=1), because I will count SKUs that were in the assortment in January, and I wanted to count those that were in January and are still there.

 

Does anyone have any idea how to count it?I would like to get a table that will show by months the number of products that were on sale in January and are still sold in each month.

 

I would be grateful for your help

Faustina

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try creating a measure like

Still on sale =
VAR JanProducts =
    CALCULATETABLE (
        VALUES ( Assort[ProductId] ),
        MONTH ( Assort[AssortDate] ) = 1
    )
VAR CurrentMonth =
    MONTH ( MAX ( 'Date'[Date] ) )
VAR CurrentProducts =
    CALCULATETABLE (
        VALUES ( Assort[ProductId] ),
        MONTH ( Assort[AssortDate] ) = CurrentMonth
    )
RETURN
    COUNTROWS ( INTERSECT ( CurrentProducts, JanProducts ) )

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Try creating a measure like

Still on sale =
VAR JanProducts =
    CALCULATETABLE (
        VALUES ( Assort[ProductId] ),
        MONTH ( Assort[AssortDate] ) = 1
    )
VAR CurrentMonth =
    MONTH ( MAX ( 'Date'[Date] ) )
VAR CurrentProducts =
    CALCULATETABLE (
        VALUES ( Assort[ProductId] ),
        MONTH ( Assort[AssortDate] ) = CurrentMonth
    )
RETURN
    COUNTROWS ( INTERSECT ( CurrentProducts, JanProducts ) )

Thank you so much for a help!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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