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

Data for last 3 months, but current month from yesterday

Hi im trying to create a measure that display data from last 3 months but only from yesterday in current month.

 

Let say we have the total budget for jan - mar like this:

 

Petter120_0-1616319234794.png

 

What i need the measure to display it like this:

Petter120_1-1616319383581.png

 

I have worked with this measure but it is summarizing everything in march:

CALCULATE(SUM(P_Plan_Ras[Plan_Kton]), CALENDAR(DATE(YEAR(TODAY()) - 3,MONTH(TODAY()),DAY(TODAY())),TODAY()) 




Thanks
Petter 

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

Please correct me if I wrongly understood.

Please try the below.

The link to the pbix file is down below.

 

Budget MTD until today =

VAR untiltoday =
TODAY ()
VAR result =
CALCULATE (
SUMX (
FILTER (
ALLSELECTED ( 'Calendar' ),
[date] <= untiltoday
),
[Budget Total]
),
VALUES ( 'Calendar'[Month Name] )
)
RETURN
result

 

Picture1.png

 

 

 

https://drive.google.com/file/d/18vb0hhFwyK2lt8fkCMchgClU0W5MhKaC/view?usp=sharing 

 

Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

v-jingzhang
Community Support
Community Support

Hi @Petter120 

I have another idea to use visual-level filters to realize the same goal. Suppose your budget data is based on daily data like below and have data in multiple years. You can add a column YearMonth in the table to use in filters and measures later.

032301.jpg

Create a measure Flag to determine whether a month is in last three months. If it is, return the result 1.

Flag = 
VAR _startDate = EOMONTH(TODAY(),-3)+1
VAR _startYearMonth = YEAR(_startDate)*100+MONTH(_startDate)
VAR _currentYearMonth = YEAR(TODAY())*100+MONTH(TODAY())
RETURN
IF(SELECTEDVALUE('Table'[YearMonth])>=_startYearMonth && SELECTEDVALUE('Table'[YearMonth])<=_currentYearMonth, 1)

Put Month and Budget columns into the table as values, and add two fields Date and Flag into its visual-level filters. Filter the Date with Relative date in the last 3 months (not include today) and filter the Flag is 1.

032302.jpg

Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @Petter120 

I have another idea to use visual-level filters to realize the same goal. Suppose your budget data is based on daily data like below and have data in multiple years. You can add a column YearMonth in the table to use in filters and measures later.

032301.jpg

Create a measure Flag to determine whether a month is in last three months. If it is, return the result 1.

Flag = 
VAR _startDate = EOMONTH(TODAY(),-3)+1
VAR _startYearMonth = YEAR(_startDate)*100+MONTH(_startDate)
VAR _currentYearMonth = YEAR(TODAY())*100+MONTH(TODAY())
RETURN
IF(SELECTEDVALUE('Table'[YearMonth])>=_startYearMonth && SELECTEDVALUE('Table'[YearMonth])<=_currentYearMonth, 1)

Put Month and Budget columns into the table as values, and add two fields Date and Flag into its visual-level filters. Filter the Date with Relative date in the last 3 months (not include today) and filter the Flag is 1.

032302.jpg

Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

This way works as well 🙂

Jihwan_Kim
Super User
Super User

Hi,

Please correct me if I wrongly understood.

Please try the below.

The link to the pbix file is down below.

 

Budget MTD until today =

VAR untiltoday =
TODAY ()
VAR result =
CALCULATE (
SUMX (
FILTER (
ALLSELECTED ( 'Calendar' ),
[date] <= untiltoday
),
[Budget Total]
),
VALUES ( 'Calendar'[Month Name] )
)
RETURN
result

 

Picture1.png

 

 

 

https://drive.google.com/file/d/18vb0hhFwyK2lt8fkCMchgClU0W5MhKaC/view?usp=sharing 

 

Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thank you works fine 🙂

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.