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

Set Analysis with a varied Date according to each dimension

Hi,

My data source is a flat table with the following fields:

    EmployeeName

    TrainingDate: Date that the employee received training, under the format: dd-MMM-yy

    ReportingMonth: Last day of the month, under the format: MMM-yyyy

    CarSold: Number of cars sold within that month

    ...(other fields irrelevant to this question)

Flat table looks somewhat like this:

ReportingMonthEmployeeNameCarSoldTrainingDateother irrelevant fields
Dec-2016A611-Jun-15
Dec-2016B825-Sep-16
Dec-2016C75-Dec-16
Dec-2016D830-Aug-16
Dec-2016E68-Oct-15
Nov-2016A311-Jun-15
Nov-2016B225-Sep-16
Nov-2016C45-Dec-16
Nov-2016D330-Aug-16
Nov-2016E28-Oct-15

I want to create a table in QlikSense that show the total number of car sold by each Employee during the month of his/her training. So far my table is like this:

EmployeeNameTrainingDateTraining MonthCar Sold in Training Month
A11-Jun-15Jun-2015...
B25-Sep-16Sep-2016...
C5-Dec-16Dec-2016...
D30-Aug-16Aug-2016...
E8-Oct-15Oct-2015...

Formula for each column:

    Dimension: =EmployeeName

    Measure 1: =TrainingDate

    Measure 2: =Date(TrainingDate,'MMM-yyyy')

    Measure 3: =sum({<[Other Fields] = {'Other Field values'}, ReportingMonth = {'$(=Date(TrainingDate,'MMM-yyyy'))'}>} CarSold)

I could not get the Measure 3 column to work. How should I write this formula differently?

If this is too much for set analysis, I probably can get rid of the Date(...) formula by changing the format of the TrainingDate to match the ReportingMonth right from the loading script. I'm more concerned of how to get the ReportingMonth to vary with the Dimension.

Thanks a lot! Please let me know if you have any question.

10 Replies
Not applicable
Author

I stripped my formula to the bare minimum, essentially this:

=sum({<ReportingMonth>} if(monthstart(ReportingMonth) =monthstart(TrainingDate), CarSold))

And it still doesn't work if I'm keeping the current selection to ReportingMonth='Dec-2016'.

What it shows is: For Employee trained in Dec-2016, it sums all CarSold in all the months

                          For Employee trained on a different month, it returns 0

If I change my selection to ReportingMonth='Jul-2016',

What it shows is: For Employee trained in Jul-2016, it sums all CarSold in all the months

                          For Employee trained on a different month, it returns 0

Again, all is fine if I cancel the ReportingMonth selection.

Thanks! Really appreciate your help.