Forum Discussion
Understanding Multiple Fact Tables
Thanks for the approach, my data for each customer, there is also specific "start date" and "end date" columns ( for example a 50% discount program apply for customer A , from 1/1/2021 to 20/1/2021 ) , how to calculate the sales for the campaign ?
It would be helpful if you provided sample data in tabular form
- VuongLM934 years agoHelper III
https://docs.google.com/spreadsheets/d/1g28W34c8Z9MAgbdAYwyveYIiABKjwekD/edit#gid=1517233207
Above is a sample data , which I made up for explaining my case,
- PaulDBrown4 years agoCommunity Champion
See if this works, though the performance is slow:
Sales By Campaign & Customer = VAR StartDate = CALCULATE ( MAX ( 'Campaign Table'[Start Date] ), ALLEXCEPT ( 'Campaign Table', 'Campaign Table'[CampaignID] ) ) VAR StartKey = INT ( DAY ( StartDate ) & MONTH ( StartDate ) & YEAR ( StartDate ) ) VAR EndDate = CALCULATE ( MAX ( 'Campaign Table'[End Date] ), ALLEXCEPT ( 'Campaign Table', 'Campaign Table'[CampaignID] ) ) VAR EndKey = INT ( DAY ( EndDate ) & MONTH ( EndDate ) & YEAR ( EndDate ) ) RETURN CALCULATE ( [Sum Sales], CROSSFILTER ( 'Campaign Table'[Customer Code], 'Customer Table'[Customer Code], BOTH ), FILTER ( ALL ( 'Sales Table'[DateKey] ), 'Sales Table'[DateKey] >= StartKey && 'Sales Table'[DateKey] <= EndKey ) )I've attached the sample PBIX file
- Ashish_Mathur4 years agoSuper User
Hi,
My approach would be to write a calculated column formula in the Campaign Table to get the Amount from the Fact- Sales Orders Table. For this we will have to first convert the DateKey column into an actual date column (the way dates are in the Campaign table). Once we have the Amount column in the Campaign table, we just have to write a simple SUM measure.
Are you OK with this approach.
- VuongLM934 years agoHelper III
Hi Ashish_Mathur , how to create this calculated column to get the according amount from the Sales table ? since there is 2 dates column , in Excel I would use SumIfs to calcualte the sales mount between the Start date and End Date of the campaign; would be helpful if you could help write an example