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
win_anthony
Resolver III
Resolver III

How to Show Previous Value with Varying Dates

The goal is to highlight employee transactions vs the employee's varying schedule. The problem is that each employee has varying schedules (ex: some work daily / weekly / monthly ). I was successful at creating a measure that can reflect the employee's previous transactions but struggle reflecting dates in which there are no transactions in conjunction with their work schedule. Any advice on how I can reflect continuous date entries which corresponds with the employee's schedule?

 

Below you will find the following: Previous Transaction Measure / Measure for Continuous Dates / Sample Dimension Table / Sample Fact Table

 

Your support/advice is greatly appreciated. 

 

[Previous Transaction Count] measure >> This works well as it will give me the previous transaction count but will skip any dates where there are no data

 

VAR _selDate = SELECTEDVALUE( 'Calendar'[Date] )
VAR _maxDate = CALCULATE(
                    LASTNONBLANK( 'Calendar'[Date], 
                        CALCULATE( [Transaction_Count] )
                        )
                    , FILTER(
                        ALLSELECTED( 'Calendar' ), 'Calendar'[Date] < _selDate)
                    )
RETURN
IF(
    NOT(
        ISBLANK( [Transaction_Count] )
        ),
    CALCULATE(
        [Transaction_Count], 
        FILTER(
            ALLSELECTED( 'Calendar' ),
            'Calendar'[Date] = _maxDate
            )
        ), BLANK()
)

 

Current Measure for Continuous Dates >> This works but does not reflect well for employees which does not have a daily schedule (ex: employees with weekly or monthly schedules will have 0 value dates for each individual day leading up to their next transaction). The goal is to try and have dates which correspond to their schedule even if there is no data (ex: if employee works weekly, the date output should follow a weekly cadance. Same for monthly).

 

IF(
    [Previous Transaction Count] = BLANK(),
    0,
    [Previous Transaction Count]
)

 

Sample Dimension Table >> Notice column = Emp_Schedule (this will give the cadance in which date output should follow)

Emp_idEmp_TeamEmp_ScheduleEmp_Start_Date
1PizzaWeeklyFriday
2PizzaWeeklyWednesday
3BurgersDaily 
4BurgersMonthly28

Sample Fact Table

Emp_TeamEmp_ScheduleTrans_CountTrans_DatePrevious_Value [Expected Output]Explanation_For_Previous_Value
PizzaWeekly108/3/20210 
PizzaWeekly58/10/202110 
PizzaWeekly08/20/20215 
PizzaWeekly08/27/20210Notice the week prior, there were no transaction. The goal is to reflect this week (date) if there are no transactions.
PizzaWeekly159/3/20210Notice the week prior, there were no transaction. The goal is to reflect this week (date) if there are no transactions.
PizzaWeekly28/2/20210 
PizzaWeekly08/11/20212 
BurgersDaily38/1/20210 
BurgersDaily128/2/20213 
BurgersDaily08/3/202112 
BurgersDaily08/4/20210Notice the day prior, there were no transaction. The goal is to reflect this day (date) if there are no transactions.
BurgersDaily108/5/20210Notice the day prior, there were no transaction. The goal is to reflect this day (date) if there are no transactions.
BurgersMonthly158/12/20210 
BurgersMonthly98/29/202115 
BurgersMonthly09/29/20219 
BurgersMonthly310/31/20210Notice the month prior, there were no transaction. The goal is to reflect this month (date) if there are no transactions.
3 REPLIES 3
Icey
Community Support
Community Support

Hi @win_anthony ,

 

I have one question: Pizza's schedule is weekly. Why was he scheduled twice in weeks "8/1/2021 - 8/7/2021" and "8/8/2021 - 8/14/2021"?

 


 

Sample Fact Table

Emp_Team Emp_Schedule Trans_Count Trans_Date Previous_Value [Expected Output] Explanation_For_Previous_Value
Pizza Weekly 10 8/3/2021 0  
Pizza Weekly 5 8/10/2021 10  
Pizza Weekly 0 8/20/2021 5  
Pizza Weekly 0 8/27/2021 0 Notice the week prior, there were no transaction. The goal is to reflect this week (date) if there are no transactions.
Pizza Weekly 15 9/3/2021 0 Notice the week prior, there were no transaction. The goal is to reflect this week (date) if there are no transactions.
Pizza Weekly 2 8/2/2021 0  
Pizza Weekly 0 8/11/2021 2  
Burgers Daily 3 8/1/2021 0  
Burgers Daily 12 8/2/2021 3  
Burgers Daily 0 8/3/2021 12  
Burgers Daily 0 8/4/2021 0 Notice the day prior, there were no transaction. The goal is to reflect this day (date) if there are no transactions.
Burgers Daily 10 8/5/2021 0 Notice the day prior, there were no transaction. The goal is to reflect this day (date) if there are no transactions.
Burgers Monthly 15 8/12/2021 0  
Burgers Monthly 9 8/29/2021 15  
Burgers Monthly 0 9/29/2021 9  
Burgers Monthly 3 10/31/2021 0 Notice the month prior, there were no transaction. The goal is to reflect this month (date) if there are no transactions.

 

Best Regards,

Icey

@Icey thank you so much for your response. Apologies but the highlighted Pizza entry for 8.2.2021 + 8.11.2021 was entered in error. This was just a mock sample data set where I was trying to show the expected output. Please disregard the entry for 8.2.2021 + 8.11.2021. Apologies for any confusion. 

win_anthony
Resolver III
Resolver III

@amitchandak  @MFelix  @AlB  @parry2k  Greetings. Would you be so kind as to provide any advice if possible? Your support is greatly appreciated. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.