The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi all,
I have a table, with columns showing the numbers I want to add up, and columns containing date between which I would not want to add them up.
For example:
Number Date from Date to
5 13/4 15/4
10 14/4 20/4
5 22/4 25/4
I want to create a second table with a daily tally of the total of the "Number" column, but onkly if the date in question is outside the "Date from - date to" range. Either as a conditional column, or as a measure. For example:
Day TOTAL
11/4 20
12/4 20
13/4 15
14/4 5
etc.
I tried to use the CALCULATE ( SUM(), FILTER()) functionality, but could not get it to work. Is that the right approach? Or is there a better way to do this?
Solved! Go to Solution.
Hi @User1 ,
Please create a new date table firstly. And there is not a relationship between the tables.
Example:
Date = CALENDAR(DATE(2020,4,1),DATE(2020,5,1))
Then create a measure like this:
Measure =
CALCULATE (
SUM ( 'Table'[Number] ),
FILTER (
'Table',
MAX ( 'Date'[Date] ) < 'Table'[Date From]
|| MAX ( 'Date'[Date] ) > 'Table'[Date To]
)
)
For more details, please see the attachment.
Hi @User1 ,
Please create a new date table firstly. And there is not a relationship between the tables.
Example:
Date = CALENDAR(DATE(2020,4,1),DATE(2020,5,1))
Then create a measure like this:
Measure =
CALCULATE (
SUM ( 'Table'[Number] ),
FILTER (
'Table',
MAX ( 'Date'[Date] ) < 'Table'[Date From]
|| MAX ( 'Date'[Date] ) > 'Table'[Date To]
)
)
For more details, please see the attachment.
Thanks, in the end I got it to work, but I had to use the OR() statement instead of the || (which I assume does the same)?
Thanks anyways 🙂
User | Count |
---|---|
69 | |
64 | |
62 | |
55 | |
28 |
User | Count |
---|---|
203 | |
82 | |
65 | |
48 | |
38 |