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
joshua1990
Post Prodigy
Post Prodigy

Count New and Missing Entries compared to previous week

I have a transactional table that contains all Items/ Products, that were sold in the corresponding week.

The table has a structure like this:

DateProductValue
08.02.2021AA1100
08.02.2021AA2105
08.02.2021AA3100
15.02.2021AA1100
15.02.2021AA4100

 

This table is linked with our calendar table and our Department Dimensional table.

The entries are made once every week.

Now I would like to determine 3 results:

  1. How many different/ unique Products were sold per week
  2. How many new products were sold compared to the previous week
  3. How many old products (no entry) were sold compared to the previous week.

How would you calculate this?

In the end, I would like to use a Matrix with a Department Level as a row to show these results.

 

7 REPLIES 7
stevedep
Memorable Member
Memorable Member

Hi,

 

Please see below for a potential solution to your question. A measure is calculated to sum the sales in the period (week or month) before. You can then filter our records with of without sales in the previous period.

Working code available here

 

Hope it helps.

 

stevedep_0-1613654570093.png

 

jameszhang0805
Resolver IV
Resolver IV

Hi joshua1990:

         Your request is similar to the calculation of New Customer Old customer, and Return Customer. So the first thing you need to clearly define what is the New production ?
1. the week of the current filter contents = the week of the first sales week in your whole fact table 
2. OR  the week of the current filter contents = the week of the launch date week in your product dimension table
If the definition is 1, SQLBI.com DAX Pattern has the article to explain how to calculate. 

 

 

lbendlin
Super User
Super User

Yes, but these would be dynamic table variables that you can create directly in DAX and then throw away again when you return the results.  That way you can compare any time period to any other time period in a flexible way.  I wouldn't be worried about peformance for that. Of course you'll have to test it and see if you get acceptable performance out of it.

lbendlin
Super User
Super User

you stuff the transactions for the two dates you want to compare into separate table variables and the use EXCEPT() to find the difference.

 

Let's say table A are the products sold on Feb 8 and table B the products sold on Feb 15.

 

EXCEPT (B,A) answers question 2, EXCEPT(A,B) answers question 3.

Thanks. Is there any other way?

There are always multiple ways to do that. What do you not like about my proposal?

@lbendlin Thank you so much for your support! I am just wondering - from a Dax Performance Point of View - if this is a good approach If I use to review the last 3 years on a weekly basis. Please correct me if I am wrong, but EXCEPT compared tables. That would mean that I have to create a table for each week, right?

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.

Top Solution Authors