Forum Discussion
Return Latest Value Using Date Slicer
- Anonymous4 years ago
Hi sya,
Please try this code. it works here with the provided pwbi
new measure =VAR yearmax =CALCULATE ( MAX ( 'Date'[Year] ), REMOVEFILTERS ( 'Date' ) )VAR monthselect =SELECTEDVALUE ( 'Date'[Month Name] )var monthnumb=CALCULATE(max('Date'[Month]),'Date'[Month Name]=monthselect)VAR _Datemax =date(yearmax,monthnumb,1)VAR _Maxdatedsoalldates =CALCULATE ( MAX ( Sheet1[Month] ), REMOVEFILTERS ( 'Date' ) )VAR _Maxdatedso =CALCULATE ( MAX ( Sheet1[Month] ),'Date'[Year]=yearmax)var dsomaxperiod=CALCULATE ( [DSO Allocated],Sheet1[Month]=_Maxdatedsoalldates)VAR result =if(ISBLANK(_Maxdatedso),CALCULATE ( [DSO Allocated],Sheet1[Month]=_Maxdatedsoalldates,REMOVEFILTERS('Date'[Month Name])),IF (_Maxdatedso <= _Datemax,CALCULATE ( [DSO Allocated],'Date'[Year]=yearmax)))RETURNresult - 4 years ago
Hi,
Try these measures
Measure = CALCULATE([DSO Allocated],LASTNONBLANK('Date'[Date],CALCULATE([DSO Allocated])))Measure 2 = maxx(summarize(calculatetable('Date',datesbetween('Date'[Date],date(2022,1,1),[Last date of selected month])),'Date'[Year],'Date'[Month Name],"ABCD",[Measure]),[ABCD])Hope this helps.
Hello again sir Ashish_Mathur
Can i have the formula for measure [Last date of selected month] that u used in Measure 2?
Thank you very much!
=eomonth(date(2022,max(Date[month]),1),0)
- sya4 years agoHelper I
thank you sir!! u r the best <3<3
- Ashish_Mathur4 years agoSuper User
You are welcome. Thank you for your kind words.
- sya3 years agoHelper I
Hello Sir Ashish_Mathur ,
Now my data is updated with May 2022, June 2022 and July 2022 data.
But when i set the month slicer to May, June, July, the DSO for 2022 remains at April 2022 figure which is 60.1.
It is supposed to show the latest figure, which means, if I selected Jan-July, DSO 2022 should show July 2022 figure.
Please help, thank you
- Ashish_Mathur3 years agoSuper User
Share the download link of your PBI file.
- sya3 years agoHelper I
Hi, Below is the link. Let me know if you have trouble accessing it
https://drive.google.com/drive/folders/1ycc45tQdHk0CqPamVchdSyw8sYB6Qf4I?usp=sharing
Thanks
- Ashish_Mathur3 years agoSuper User
Hi,
The file there is not in a .pbix format. Please share the file which opens in PBI Desktop.
- sya3 years agoHelper I
Hi, I've reshared at the same link. Please check
Thank you.
Sya
- Ashish_Mathur3 years agoSuper User
Drag Measure instead of Measure2 in the card visual.
- sya3 years agoHelper I
Oh gosh.. thank you sir. What would i do without you.
If it is not too much, can you so kindly explain the mechanism of those two formulas..?
Regards,
Sya