Forum Discussion
Anonymous
1 year agoNot applicable
Dynamic Measure for Card Visual
Hi. I am working on a card visual. The card is supposed to do two three things: 1. Show the current Red Score (an average of a column called KPI), which refers to a column called kpi_name, which h...
- 1 year ago
Hi Anonymous
1 Create DimDate
Dim_Date = VAR MinDate = MIN(Traxx[session_date]) VAR MaxDate = MAX(Traxx[session_date]) RETURN ADDCOLUMNS( CALENDAR(MinDate, MaxDate), "Day", DAY([Date]), "Month", MONTH([Date]), "MonthName", FORMAT([Date], "MMMM"), "Quarter", "Q" & QUARTER([Date]), "Year", YEAR([Date]), "YearMonth", FORMAT([Date], "yyyy-MM"), "MonthYearShort", FORMAT([Date], "MMM-yy"), "IsWeekend", WEEKDAY([Date], 2) > 5 )
2 Create measures
Current RED Score = CALCULATE( AVERAGE(Traxx[KPI]), Traxx[kpi_name] = "Red Score" )
Previous RED KPI = VAR CurrentDate = MAX(Dim_Date[Date]) // Gets the current date from context VAR PreviousMonthStart = DATE(YEAR(CurrentDate), MONTH(CurrentDate) - 1, 1) // Start of previous month VAR PreviousMonthEnd = EOMONTH(PreviousMonthStart, 0) // End of previous month RETURN CALCULATE( AVERAGE(Traxx[KPI]), Traxx[kpi_name] = "Red Score", Dim_Date[Date] >= PreviousMonthStart, Dim_Date[Date] <= PreviousMonthEnd, REMOVEFILTERS(Dim_Date[MonthYearShort]) // Clears the current month filter )
Growth % = DIVIDE( [Current RED Score] - [Previous RED KPI], [Previous RED KPI], 0 // Returns 0 in case of division by zero )
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.
Elena_Kalina
1 year agoSolution Sage
Hi Anonymous
1 Create DimDate
Dim_Date = VAR MinDate = MIN(Traxx[session_date]) VAR MaxDate = MAX(Traxx[session_date]) RETURN ADDCOLUMNS( CALENDAR(MinDate, MaxDate), "Day", DAY([Date]), "Month", MONTH([Date]), "MonthName", FORMAT([Date], "MMMM"), "Quarter", "Q" & QUARTER([Date]), "Year", YEAR([Date]), "YearMonth", FORMAT([Date], "yyyy-MM"), "MonthYearShort", FORMAT([Date], "MMM-yy"), "IsWeekend", WEEKDAY([Date], 2) > 5 )
2 Create measures
Current RED Score = CALCULATE( AVERAGE(Traxx[KPI]), Traxx[kpi_name] = "Red Score" )
Previous RED KPI = VAR CurrentDate = MAX(Dim_Date[Date]) // Gets the current date from context VAR PreviousMonthStart = DATE(YEAR(CurrentDate), MONTH(CurrentDate) - 1, 1) // Start of previous month VAR PreviousMonthEnd = EOMONTH(PreviousMonthStart, 0) // End of previous month RETURN CALCULATE( AVERAGE(Traxx[KPI]), Traxx[kpi_name] = "Red Score", Dim_Date[Date] >= PreviousMonthStart, Dim_Date[Date] <= PreviousMonthEnd, REMOVEFILTERS(Dim_Date[MonthYearShort]) // Clears the current month filter )
Growth % = DIVIDE( [Current RED Score] - [Previous RED KPI], [Previous RED KPI], 0 // Returns 0 in case of division by zero )
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.