Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
ChihiroWa
Frequent Visitor

DATESBETWEEN function error

Hi, I hope someone help me with a DATESBETWEEN function error.

 

 Prepared tables are like below:

 Table A : a period of item production

CountrySegmentsItem namePeriod - startPeriod - end
JapanAxxx2013/1/12015/12/31
JapanAyyy2010/1/12020/12/31
JapanBzzz2020/1/12025/12/31
IndiaAaaa2018/1/12020/12/31
IndiaCbbb2040/1/12045/12/31
IndonesiaBccc2030/1/12035/12/31
IndonesiaCddd2025/1/12030/12/31
・・・・・・・・・・・・・・・

 

 Table B : global market volume

CountyCYVolume
Japan20201000000
Japan20211200000
Indonesia20202000000
・・・・・・・・・

 

What I want to do is :  changing x-axis of a graph by selecting country

e.g. Japan -> from 2010 to 2025

・a slicer

ChihiroWa_1-1691549015809.png

 

・a gragh

ChihiroWa_0-1691548979439.png

 

 

What I tried:  DATESBETWEEN function

period for x-axis = DATESBETWEEN(TableB'[CY],FIRSTDATE('TableA'[Period - start]),LASTDATE('TableA'[Period - end]))
 
error : 
ChihiroWa_2-1691549665943.png

 

Thanks,

Chihiro

 
4 REPLIES 4
danextian
Super User
Super User

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] )
    )
)

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@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.

 

danextian_0-1691551947198.png

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>)

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.

CY[date] = 'TableB'[CY])&"/01/01"

 

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.