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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
sekinod
Helper II
Helper II

Getting Values for relevant period

Current model can show data as below

11.PNG

 

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

 

 

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

 

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 

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @sekinod ,

 

Can you explain in detail about achievement measure and target measure?

It is best to explain in the form of examples, thank you.

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

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.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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