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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Display product name by last week, Week-2, Week-3 ...

Hello,

 

i need some help.

 

I have data like that : 

 

Aho00_4-1653387161977.png

 

 

For example : in Green it's the data from previous week, in red from 2 weeks ago, etc...

So i want the last 3 weeks from today

 

 And i would like to be like that in Power BI

Aho00_2-1653387076591.png

 

Thanks for you help.

 

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could enter another table like below:

vyalanwumsft_0-1653642544083.png

Then create a measure:

diff = DATEDIFF(MAX('Table'[Date]),TODAY(),WEEK)
Measure = 
SWITCH(MAX('Table (2)'[WEEK]),"Week 1",CALCULATE(MAX('Table'[Product]),FILTER('Table',[diff]=1)),
"Week 2",CALCULATE(MAX('Table'[Product]),FILTER('Table',[diff]=2)),
"Week 3",CALCULATE(MAX('Table'[Product]),FILTER('Table',[diff]=3)))

The final show:

vyalanwumsft_1-1653642599095.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could enter another table like below:

vyalanwumsft_0-1653642544083.png

Then create a measure:

diff = DATEDIFF(MAX('Table'[Date]),TODAY(),WEEK)
Measure = 
SWITCH(MAX('Table (2)'[WEEK]),"Week 1",CALCULATE(MAX('Table'[Product]),FILTER('Table',[diff]=1)),
"Week 2",CALCULATE(MAX('Table'[Product]),FILTER('Table',[diff]=2)),
"Week 3",CALCULATE(MAX('Table'[Product]),FILTER('Table',[diff]=3)))

The final show:

vyalanwumsft_1-1653642599095.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello, 

Thanks for the answer.

 

I had some issues with your solution because my tables are a little different but i managed to make it works somehow with your help

Thank you.

Have a nice day.

amitchandak
Super User
Super User

@Anonymous , Create a week start date

 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1

 

Then create a rank column

rank = rankx(filter(Table, Table[Week Start date] =earlier([Week Start date]) ), [Product])

 

Now in a matrix visual

Rank Rank on row , Date on Column, and max of product as value

Anonymous
Not applicable

Hello, thanks for the answer. 

It works somehow but not like as i wanted.

 

I'm sorry, it might be a little long.

 

I have some issues :

1) if i have for example 10 weeks of data, it will create 10 columns for each week but what i want it's only the 3 last week.

 

2) in fact my data looks like that :

Aho00_2-1653397144500.png

 

But if i filter it by actual stock = "-" 

 

Aho00_3-1653397192507.png

Then i got that : (i want to get rid of the empty cells and move the others num product higher

 

Aho00_5-1653397345285.png

 

3) I want to rename myself these columns by week-2 and week-1 but i can't do that here

Aho00_6-1653397511349.png

 

 (Usually i have 1 field for 1 column) but here i have one field 'date' for x Column

Normally, I rename them here :

 

Aho00_7-1653397567353.png

 

4) It is possible to have this table without the column rank? just 3 column, week-3, week-2 and week-1?

Thanks again

 

 

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.