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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sekinod
Helper II
Helper II

Getting Values for relevant period

Current model can show data as below

 

what happen here is when the date is selected, all months' end values shown prior to selected month and last row shows the selected month value up to selected date. It was achieved by following measure

 

11.PNG

Target measure = 
VAR selectedYear_ = SELECTEDVALUE ( AuxDates[Year] )
VAR selectedYM_ = SELECTEDVALUE ( AuxDates[Year MonthNr] )
VAR selectedDate_ = SELECTEDVALUE ( AuxDates[Date] )
VAR currentYear_ = SELECTEDVALUE ( Dates[Year] )
VAR currentYM_ = SELECTEDVALUE ( Dates[Year MonthNr] )
VAR currentDate_ = SELECTEDVALUE ( Dates[Date] )
RETURN
    IF (
        currentYear_ = selectedYear_,
        SWITCH (
            TRUE (),
            currentYM_ < selectedYM_,
                IF (
                    EOMONTH ( currentDate_, 0 ) = currentDate_,
                    CALCULATE ( SUM ( Target[Amount] ), Target[Product] IN { "FD", "1", "2", "3" } )
                ),
            currentYM_ = selectedYM_,
                IF (
                    currentDate_ = selectedDate_,
                    VAR totalTargetMonth_ =
                        CALCULATE (
                            SUM ( Target[Amount] ),
                            Dates[Date] = EOMONTH ( currentDate_, 0 ),
                            Target[Product] IN { "FD", "1", "2", "3" }
                        )
                    VAR totalWDaysInMonth_ =
                        CALCULATE (
                            SUM ( Dates[Working Day] ),
                            Dates[Year MonthNr] = currentYM_,
                            ALL ( Dates )
                        )
                    VAR totalWDaysInPeriod_ =
                        CALCULATE (
                            SUM ( Dates[Working Day] ),
                            Dates[Year MonthNr] = currentYM_,
                            Dates[Date] <= currentDate_,
                            ALL ( Dates )
                        )
                    VAR ratio_ =
                        DIVIDE ( totalWDaysInPeriod_, totalWDaysInMonth_ )
                    RETURN
                        totalTargetMonth_ * ratio_
                )
        )
    )

I need to connect another table to this model which is shown below.

 

2.PNG

 

The result expected is as follows

3.PNG

Achievement column values are getting from Deposits table "Value" columns. Calculation here should be that total value against the month of date shown in first column(if it less than month end total up to that date within the month) and It should be subtracted by the previous month's total value.

 

Thank for your help.

 

Downlod:

sample.pbix 

 

1 REPLY 1
amitchandak
Super User
Super User

@sekinod , Not very clear. But you can use time intelligence and date table to get this month vs lasy month values and use those

example

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
this month =MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH('Date'[Date])))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value =  CALCULATE(sum('Table'[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series 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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.