Reply
lemaribdb
Helper II
Helper II

DAX DATESINPERIOD moving to different measure issue

Hi guys!

I have below DAX measure and it works correctly.

Date Range Text =
VAR MaxDate = MAX(X_Calendar[DATE])
VAR SelectedPeriod = 'X_Relative Period'[Selected Months Back Number]
VAR Range = DATESINPERIOD('X_Relative Calendar'[DATE], MaxDate, -SelectedPeriod, MONTH)
VAR StartDate = MINX(Range, 'X_Relative Calendar'[DATE])
VAR EndDate = MAXX(Range, 'X_Relative Calendar'[DATE])
RETURN
FORMAT(StartDate, "yyyy-MM") & " to " & FORMAT(EndDate, "yyyy-MM"

I wanted to move the 3 VARS (so the VAR Range output) to different measure so it can be used by few other measures. When I split this measure into two measures:

Selected Period Range =
VAR MaxDate = MAX(X_Calendar[DATE])
VAR SelectedPeriod = 'X_Relative Period'[Selected Months Back Number]
VAR Range = DATESINPERIOD('X_Relative Calendar'[DATE], MaxDate, -SelectedPeriod, MONTH)
RETURN Range

AND

X_SW Amount Rounded No Zero Relative =
VAR Range = 'X_Relative Period'[Selected Period Range]
RETURN
CALCULATE(
    X_Measures[X_SW Amount Rounded No Zero],
    REMOVEFILTERS(X_Calendar),
    KEEPFILTERS(Range),
    USERELATIONSHIP(X_Calendar[DATE], 'X_Relative Calendar'[DATE]))

I get an error "The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column". Can you advise my why this happens and how to fix it? To my understanding I just split the measure into two. I tried troubleshooting this by creating a calculated column out of the 'Selected Period Range' and apparently a new column with date hierarchy appears there. Can you help me?


1 ACCEPTED SOLUTION
some_bih
Super User
Super User

Hi @lemaribdb 

It seems that in part X_SW Amount Rounded No Zero Relative =

VAR Range = 'X_Relative Period'[Selected Period Range] 

is issue

try to change this, maybe min or max, like VAR Range =MAX( 'X_Relative Period'[Selected Period Range])

 





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

Proud to be a Super User!






View solution in original post

1 REPLY 1
some_bih
Super User
Super User

Hi @lemaribdb 

It seems that in part X_SW Amount Rounded No Zero Relative =

VAR Range = 'X_Relative Period'[Selected Period Range] 

is issue

try to change this, maybe min or max, like VAR Range =MAX( 'X_Relative Period'[Selected Period Range])

 





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

Proud to be a Super User!






avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)