This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
Hi, I hope someone help me with a DATESBETWEEN function error.
Prepared tables are like below:
Table A : a period of item production
| Country | Segments | Item name | Period - start | Period - end |
| Japan | A | xxx | 2013/1/1 | 2015/12/31 |
| Japan | A | yyy | 2010/1/1 | 2020/12/31 |
| Japan | B | zzz | 2020/1/1 | 2025/12/31 |
| India | A | aaa | 2018/1/1 | 2020/12/31 |
| India | C | bbb | 2040/1/1 | 2045/12/31 |
| Indonesia | B | ccc | 2030/1/1 | 2035/12/31 |
| Indonesia | C | ddd | 2025/1/1 | 2030/12/31 |
| ・・・ | ・・・ | ・・・ | ・・・ | ・・・ |
Table B : global market volume
| County | CY | Volume |
| Japan | 2020 | 1000000 |
| Japan | 2021 | 1200000 |
| Indonesia | 2020 | 2000000 |
| ・・・ | ・・・ | ・・・ |
What I want to do is : changing x-axis of a graph by selecting country
e.g. Japan -> from 2010 to 2025
・a slicer
・a gragh
What I tried: DATESBETWEEN function
Thanks,
Chihiro
HI @ChihiroWa ,
DATESBETWEEN is a table function and will return a table of dates if used in creating a calculated table. If used in a measure, it is to filter an aggregation and is to be used together with CALCULATE. The correct syntax is something like
=
CALCULATE (
[Measure],
DATESBETWEEN (
TableB,
FIRSTDATE ( 'TableA'[Period - start] ),
LASTDATE ( 'TableA'[Period - end] )
)
)
@danextian ,Thanks a lot!
I found using DATESBETWEEN is not a good way to solve my problem.
If you have, could you tell me some other better ways ?
The answer really depends on your use case but information provided isnt enough to propose more appropriate one. What is the data used in your area chart? Is that volume? If so, your field pane should look something like this.
Also, the formula below will not even return a table of dates as you are comparing a year against a date.
=
DATESBETWEEN (
'TableB'[CY],
FIRSTDATE ( 'TableA'[Period - start] ),
LASTDATE ( 'TableA'[Period - end] )
)
Just DATESBETWEEN should be something like this. In your example, CY is year.
DATESBETWEEN(<Dates>, <StartDate>, <EndDate>)
Yes, the area chart shows volume, and field pane looks something like that.
Actually, Table B has thousand of rows, sorry for making confuse you.
As to CY, I prepared 'CY[date]' to recognize CY as a date.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 25 | |
| 23 | |
| 20 | |
| 18 | |
| 14 |
| User | Count |
|---|---|
| 22 | |
| 20 | |
| 20 | |
| 20 | |
| 20 |