Forum Discussion
Help Variable date measure
Hi Everyone,
Need your help with something - Not even sure if it's possible to achieve this.
I have the next table with 3 columns:
Customer | Booking Date | Booking Reference
A 01/01/2024 ABC1
A 02/01/2024 DDD1
A 7/01/2024 4567
B 10/02/2024 CDB2
Main issue is that the periods below needs to be changed somehow manually by the customers and I'm not sure how I can create a measure based on X and Y dates, however this to reflect on the dates the customer choose or entered in a filter or something like this in PBI
Now I'm trying to find out two things:
- we offer discounts for booking made in X period so trying to find out in that period how many bookings we've made per customer (I.e period 01/01/2024 - 02/01/2024)
- also, trying to find out in the Y period (usually this is 7-10 days after the above period, so 03/01/2024 - 10/01/2024) how many bookings we've had per customer
This will result for customer A in 2 for first period (period with discounts) and 1 bookings in the period without discounts.
I also need to see the difference in percentage between the periods - this will show a 100% increase (2-1 / 1)
| Customer | Discount | without discount | variance |
| A | 2 | 1 | 100% |
Is there a way to create a variable measure for the dates? This will need to store 2 variable dates, one for "period with discounts" and another for "period without discounts"
Thank you for your help!
6 Replies
- Daniel29195Community Champion
- GeorgetimesFrequent Visitor
Hi Daniel29195
Sorry, I wasn't clear enough. The issue is that we don't store anywhere this data. We just agree with customers that from period X you'll have a discount of 10% for example.
That's why I need a filter or something like this were the big managers can come, add X dates for "period with discount" and Y dates for period without discount.
I know this can be done with two filters and two tables so I'll get:
table 1
Customer Discount A 2 table 2
Customer without discount A 1 But I don't know how I can store those numbers in order to calculate the difference (2 minus 1) divided by 1
- Daniel29195Community Champion
ok i think i got you .
create a table to store this data as follow : ( example name : Discount_tbl)
let us say , discount 10% between 2023-01-01 and 2023-01-10
then your table would be as follow :
date discount discount_status
2023-01-01 0.1 with discount
2023-01-02 0.1 with discount
2023-01-03 0.1 with discount
2023-01-05 0.1 with discount
.....
2023-01-11 0 without discount
from here, you should have a dimdate which should be linked to this table .
A dimcustomer = distinct(table_name[customer-column]) ( you can use this to create w dimcustomer if you dont have it in your model ) .
and your table :
Customer | Booking Date | Booking Reference
A 01/01/2024 ABC1
A 02/01/2024 DDD1
A 7/01/2024 4567
B 10/02/2024 CDB2
from here, you can create a calculated column in your table :
discount_status = related ( discount_table[discount_status])
now you can drag and drop your columns into the visual and it will show what you want .If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. I would appreciate hitting that kudos 👍🫡