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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Get Last value previous month

Hi,

 

I need your help. I would like retreive the last value on previous calendar to a specific month.

 

My data are :

 

receipt line

SMAY_0-1641459068660.png

 

i create this measure

 

Mt YTD = TOTALYTD(SUM(ReceiptLine[MT Recept]),ReceiptDate[Date]  )

Qte YTD = TOTALYTD(SUM(ReceiptLine[Qte recept]),ReceiptDate[Date] )

Price N = DIVIDE([Mt YTD],[Qte YTD] )*

Price N-1 = IF([Mt YTD-1],
                 DIVIDE([Mt YTD-1],[Qte YTD-1])
                , [Price N])

Mt YTD (Price N-1) = SUMX( 
             ADDCOLUMNS( 
                    Summarize( ReceiptLine, ReceiptLine[ITEMID], ReceiptLine[ItempGroup], ReceiptLine[categorie appro],ReceiptDate[AnneMois])
                ,"_Mt au PRI N-1", [Qte YTD]*[Price N-1])
            , [_Mt au PRI N-1])

 

 

the final result on this report are

SMAY_2-1641459236094.png

 So I would like the empty month are fileld by the last value like this

SMAY_3-1641459380790.png

 

During my test, i created a new table base on previous formula  

 

 

Table = ADDCOLUMNS( 
                    Summarize( ReceiptLine, ReceiptLine[ITEMID], ReceiptLine[ItempGroup], ReceiptLine[categorie appro],ReceiptDate[AnneMois])
                ,"_Mt au PRI N-1", [Qte YTD]*[Price N-1]
                ,"PRI N-1", [Price N-1]
                , "Qt ", [Qte YTD])

 

 

the result like this
SMAY_1-1641459195237.png
 
How can i modify my measure "Mt YTD (Price N-1)" to have a correct data for empry month ?
 
thanks a lot for your help
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@amitchandak 

 

i found the solution with this table definition and new measure 

 

receipt Group = ADDCOLUMNS( 
                    Summarize( ReceiptLine, ReceiptLine[ITEMID],ReceiptDate[Year-month],ReceiptDate[Year])
                ,"_Mt au PRI N-1", [Qte YTD]*[Price N-1])


new measure
==>
test = CALCULATE(max('receipt Group'[_Mt au PRI N-1]),Filter('receipt Group','receipt Group'[Year]=SELECTEDVALUE(ReceiptDate[Year]) && 'receipt Group'[Year-month]<= SELECTEDVALUE(ReceiptDate[Year-month])))

SMAY_0-1641539919371.png

 

 

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , the expected value is not clear

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

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
Anonymous
Not applicable

hi @amitchandak 

 

i created a new pbix file without sensitive data based on my screenshot but i can't upload it (file type is not supported)

 

How can i share it ?

@Anonymous , upload on onedrive or dropbox and share link

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
Anonymous
Not applicable

@amitchandak 

 

i found the solution with this table definition and new measure 

 

receipt Group = ADDCOLUMNS( 
                    Summarize( ReceiptLine, ReceiptLine[ITEMID],ReceiptDate[Year-month],ReceiptDate[Year])
                ,"_Mt au PRI N-1", [Qte YTD]*[Price N-1])


new measure
==>
test = CALCULATE(max('receipt Group'[_Mt au PRI N-1]),Filter('receipt Group','receipt Group'[Year]=SELECTEDVALUE(ReceiptDate[Year]) && 'receipt Group'[Year-month]<= SELECTEDVALUE(ReceiptDate[Year-month])))

SMAY_0-1641539919371.png

 

 

Anonymous
Not applicable

You can find beelow the link to my sample data

 

sample price .pbix 

 

thanks a lot by advance

Anonymous
Not applicable

hi @amitchandak 

 

Do you have acces to the file ? 

If yes, do you have any idea on my issue ?

 

Thanks for your help

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.