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
Anonymous
Not applicable

Calculating Weekly Bucket Difference

Hello Guys,

 

the following challenge: 

For our inventory tracking, we build groups:

green = < 30 days

yellow = 30 - 90 days

red = > 90 days 

 

In Power Bi we realized that with the SWITCH statement 

Group by Age =

SWITCH(

    True(),

    fact_stock[age in days]>=90,"3. >=90 days",

    fact_stock[age in days]>=30,"2. 30 - 90 days",

     fact_stock[age in days]>=0,"1. <= 30 days"          )

 

-> this statement work fine. the age in days is in database. 

-> the fact_table is a weekly export with the following structure:

-> the unique ID  is an Stock unit ID

date

stock unit id

value

age in days

group by age

05.03.2023

12345679

100

23

< 30 days

05.03.2023

12345678

250

90

> 90 days

05.03.2023

12345677

100

89

30 - 90 days

05.03.2023

12345676

50

33

30 - 90 days

12.03.2023

12345679

50

30

30 - 90 days

12.03.2023

12345678

50

97

> 90 days

12.03.2023

12345677

null

null

consumed

12.03.2023

12345676

25

40 

30 - 90 days

12.03.2023

12345684

75

2

< 30 days

 

Following questions i have to answer every monday:

- which stock units are new in comparison to previuos week 

- which stock units are consumpted in comparison to previus week?

- which stock units changed the age bucket?

- for example: stock unit 12345678 changed from 30 - 90 days into bucket > 90 days 

 

 

How should i build this in power bi?

 

 

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

The last question is the most interesting one so i will take that up later.  For the first 2 questions, could you kinldy share the following:

  1. Download link of the PowerBI file
  2. A Calendar table with a week column in there
  3. The expected result of the first 2 questions based on the sample data that you have shared in your post.

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

To report on things that aren't there you need to use disconnected tables and crossjoins.

 

Status = 
SWITCH(TRUE(),
min(Weeks[date])=CALCULATE(min(Weeks[date]),all(Weeks[date])),BLANK(),
not isblank([val]) && isblank(calculate([Val],DATEADD(Weeks[date],-7,DAY))),"new this week",
isblank([val]) && not isblank(calculate([Val],DATEADD(Weeks[date],-7,DAY))),"consumed",
[Bucket]<>(calculate([Bucket],DATEADD(Weeks[date],-7,DAY))),"bucket change")

lbendlin_0-1680219862264.png

 

see attached

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.