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

Sum of previous Periods Grouped

Hi Experts

 

I have a column which is text and groups my values based on which month the data was uploaded into the power bi table.

i want a measure which gives me the total for the previous period (see table below) 

if i select from the slcier P06 then return back the total for P05 which is 5 and so on

UploadedMonthValuesTotal
Charging_P04Apr-2111
Charging_P05Apr-212 
Charging_P05May-2135
Charging_P06Apr-214 
Charging_P06May-215 
Charging_P06Jun-21615

 

1 ACCEPTED SOLUTION

@Anonymous 

then what's the expected output? The blank cells do not belong to any period?

pls try this

Period = 
VAR p=find("P",'Table'[Uploaded],1,0)
return if(p=0,blank(),mid('Table'[Uploaded],p+1,100)*1)

111.PNG





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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try create a column

Period = 
VAR p=find("P",'Table'[Uploaded],1)
return mid('Table'[Uploaded],p+1,100)*1

then create a measure

Measure = 
VAR p=max('Table'[Period])
return sumx(FILTER(all('Table'),'Table'[Period]=p-1),'Table'[Values])

pls see the attachment below





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

Proud to be a Super User!




Anonymous
Not applicable

Hi Ryan - thanks for the excellent feedback - how would you amend if the uploaded column had blank empty cells.

 

the following is also not working
Period =
VAR p=find("P",'Table'[Uploaded],1)
return if(not(isblank('Table'[Uploaded])) , MID('Table'[Uploaded],p+1,100)*1 , blank())

@Anonymous 

then what's the expected output? The blank cells do not belong to any period?

pls try this

Period = 
VAR p=find("P",'Table'[Uploaded],1,0)
return if(p=0,blank(),mid('Table'[Uploaded],p+1,100)*1)

111.PNG





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

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , Split Uploaded based on _ in power query into columns  https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

Then create a new table with distinct period

 

Create rank column on period

Period Rank = RANKX(all(Period),Period[period],,ASC,Dense)

 

Then you can measure like these examples
This Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])))
Last Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])-1))

Anonymous
Not applicable

Hi Amit - the Last Period = CALCULATE('Table'[Qty], FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])-1)) - is not workig getting error message the MAX function only expects column reference as an agrument

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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