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
E_K_
Helper II
Helper II

Calculate % change in [ID] where the user can input the starting month to compare to.

Want to calculate the % change in distinct count of [ID] per month, where the user can pick the starting month. the date column is [Start Time] which contains date time values, both columns are in the table 'Incidents'.

 

What I currently have (that only produces blanks, even if I filter on month.

 

Does the measure work and I need some selector visual to input the start month to compare to, or does the dax code need fixing too?

% Change =
VAR SelectedMonth = SELECTEDVALUE('Incidents'[Start Time])
VAR StartMonth = CALCULATE(
    FIRSTNONBLANK('Incidents'[Start Time], MAX('Incidents'[ID])),
    FILTER('Incidents', MONTH('Incidents'[Start Time]) < SelectedMonth)
)
VAR StartValue = CALCULATE(
    DISTINCTCOUNT('Incidents'[ID]),
    MONTH('Incidents'[Start Time]) = MONTH(StartMonth)
)
VAR EndValue = CALCULATE(
    DISTINCTCOUNT('Incidents'[ID]),
    MONTH('Incidents'[Start Time]) = SelectedMonth
)

RETURN DIVIDE(EndValue - StartValue, StartValue) * 100

 

2 REPLIES 2
amitchandak
Super User
Super User

@E_K_ , You should use date table and time intelligence

 

examples

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]))
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]))

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

@amitchandak  this clearly does not fit my use case. You are suggesting TD measures which are not what I am after

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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