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
peoplehelpme
Helper I
Helper I

Sum of of last week value from selected week

hi people . please help me to create 

sum of last week data from selected week

 

i got this date table

DateWeek numberWeek text

2021-01-03

1W1
2021-01-102W2
2021-01-173W3
2021-01-244W4
2021-01-315W5
2021-02-076W1
2021-02-147W2
2021-02-218W3
2021-02-289W4

 

and this data table (these two table are not connect in any relationship)

 

datenamevalue

2021-01-03

a1
2021-01-03b2
2021-01-10c3
2021-01-10d4
2021-01-10e5
2021-01-17f6
2021-01-17g7
2021-02-07h8
2021-02-07i9

 

when i select Jan-2021- W2 (these are 3 filters)

i want to get value 

last week=3

this week=12

 

another question is how can i do if i want to show item name

when i select Jan-2021- W2

i want to show data

last week=a,b

this week=c,d,e

 

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@peoplehelpme 

pls try to create 4 measure

 

last week value =
var _date=maxx(FILTER(all('Table'),'Table'[Date]<max('Table'[date])),'Table'[date])
return sumx(FILTER('Table 2','Table 2'[Date]=_date),'Table 2'[value])
 
this week value = sumx(FILTER('Table 2','Table 2'[Date]=max('Table'[Date])),'Table 2'[value])
 
last week item =
var _date=maxx(FILTER(all('Table'),'Table'[Date]<max('Table'[date])),'Table'[date])
return CONCATENATEX(FILTER('Table 2','Table 2'[Date]=_date),'Table 2'[name],",")
 
this week item = CONCATENATEX(FILTER('Table 2','Table 2'[Date]=max('Table'[Date])),'Table 2'[name],",")
 
11.png
 
pls see the attachment below
 
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@peoplehelpme 

pls try to create 4 measure

 

last week value =
var _date=maxx(FILTER(all('Table'),'Table'[Date]<max('Table'[date])),'Table'[date])
return sumx(FILTER('Table 2','Table 2'[Date]=_date),'Table 2'[value])
 
this week value = sumx(FILTER('Table 2','Table 2'[Date]=max('Table'[Date])),'Table 2'[value])
 
last week item =
var _date=maxx(FILTER(all('Table'),'Table'[Date]<max('Table'[date])),'Table'[date])
return CONCATENATEX(FILTER('Table 2','Table 2'[Date]=_date),'Table 2'[name],",")
 
this week item = CONCATENATEX(FILTER('Table 2','Table 2'[Date]=max('Table'[Date])),'Table 2'[name],",")
 
11.png
 
pls see the attachment below
 
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Sorry sir, I got a problem of this formula, look like it doesnt work on some week selected

last week value =
var _date=maxx(FILTER(all('Table'),'Table'[Date]<max('Table'[date])),'Table'[date])
return sumx(FILTER('Table 2','Table 2'[Date]=_date),'Table 2'[value]) ,
here is example of table1
Dateweeknumweektextyearmonth
2024-04-07171W12024apr
2024-04-14172W22024apr
2024-04-21173W32024apr
2024-04-28174W42024apr
2024-05-05175W12024may
2024-05-12176W22024may
2024-05-19177W32024may
2024-05-26178W42024may
2024-06-02179W12024jun
 
and then i got data table
namedatevalueweeknum
a2024-04-071171
b2024-04-142172
c2024-04-283174
d2024-04-284174
e2024-05-055175
f2024-05-056175
g2024-05-127176
h2024-05-128176
i2024-05-129176

 

somehow when i select 2024,may, w1 ,

the value of last week should be 7 but this formula give me 10 which is wrong please help me

@peoplehelpme 

i didn't change any DAX, the output is 7, pls see the attachment below

 

11.PNG

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.