Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all.
I have two tables A and B joined by an ID.
On each of the tables, there is a date column.
I'm trying to create a measure that counts the number of rows in which the date of table A is between the date in table B and the date in table B +1 day.
Table A
ID DateA
1 2017-03-02
2 2018-06-03
3 2019-05-13
4 2017-08-23
Table B
ID DateB
1 2017-03-01
2 2018-06-03
3 2014-05-28
4 2015-08-23
In this case, Id 1 and 2 have dates that comply with the condition, so the expected value of the measure should be 2.
Thanks in advance
Solved! Go to Solution.
Hi @Anonymous ,
I believe this is what you are looking for in the outcome.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Calculated Column
Between =
VAR _curDate = ( TableA[Date] )
VAR _curID = TableA[ID]
VAR _curTableBDate =
CALCULATE ( MAX ( TableB[Date] ), FILTER ( TableB, TableB[ID] = _curID ) )
VAR _maxPerDate = _curTableBDate + 1
RETURN
IF ( _curDate >= _curTableBDate && _curDate <= _maxPerDate, "Yes", "No" )
Measure for table in picture.
Between Dates2 =
VAR _curDate =
MAX ( TableA[Date] )
VAR _curID =
MAX ( TableA[ID] )
VAR _curTableBDate =
CALCULATE ( MAX ( TableB[Date] ), FILTER ( TableB, TableB[ID] = _curID ) )
VAR _maxPerDate = _curTableBDate + 1
RETURN
IF ( _curDate >= _curTableBDate && _curDate <= _maxPerDate, "Yes", "No" )
Measure for Card in picture.
Sum of rows = CALCULATE(COUNTROWS(TableA),TableA[Between]="Yes")
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
26 | |
21 | |
15 | |
12 |
User | Count |
---|---|
57 | |
49 | |
44 | |
19 | |
18 |