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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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