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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
slavisha84
Helper I
Helper I

How to summarize data for last week in separate column with condition?

Hello, I have a table that has 3 columns: Week, Name and Points. 

slavisha84_0-1628264852930.png

 

I need to create another table in which i am going to store data by Name for where last 4 weeks going to have their own columns with points for that week. 
Here is the challenging part, if the Name has less than 200 points in the last available week, the name will not be in the list in the new table. 

It should be like this:

slavisha84_1-1628265005186.png

 

As you can see Alabama and California are not on that list because for the last week their clicks were less than 200.

How do I do this in power BI?

Here is the sample file:
https://1drv.ms/u/s!AhhZq1add5YwjYIvuASi76lCL3R1eA?e=C7ObDZ

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @slavisha84 ,

Here are the steps you can follow:

1. Create calculated table.

Table2 =
var _1=SUMMARIZE('Table','Table'[Name],
"4WeeksAge",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])-3&&'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Points])),
"3WeeksAge",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])-2&&'Table'[Name]=EARLIER('Table'[Name]))),
"2WeeksAge",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])-1&&'Table'[Name]=EARLIER('Table'[Name]))),
"LastWeek",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])&&'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Points]>=200)))
return
FILTER(_1,[LastWeek]<>BLANK())

2. Result:

vyangliumsft_0-1628487315377.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @slavisha84 ,

Here are the steps you can follow:

1. Create calculated table.

Table2 =
var _1=SUMMARIZE('Table','Table'[Name],
"4WeeksAge",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])-3&&'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Points])),
"3WeeksAge",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])-2&&'Table'[Name]=EARLIER('Table'[Name]))),
"2WeeksAge",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])-1&&'Table'[Name]=EARLIER('Table'[Name]))),
"LastWeek",
CALCULATE(SUM('Table'[Points]),FILTER(ALL('Table'),'Table'[Week]=MAX('Table'[Week])&&'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Points]>=200)))
return
FILTER(_1,[LastWeek]<>BLANK())

2. Result:

vyangliumsft_0-1628487315377.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@slavisha84 , Create a separate week table, say date 

 

Last Week = CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Week]=max("Date"[Week])-1))

2nd  Last Week = CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Week]=max("Date"[Week])-2))

 

Last week disp = if([Last Week] < 200 , blank(),[Last Week])

2nd  Last Week = if([Last Week] < 200 , blank(),[2nd  Last Week])

 

Same need to be done for other measures too

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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