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.
Hello:
I have 3 columns:
its looks like this:
r12from: 32021 means (MM-YYYY or 03-2021)
r12to: 22022 means (02-2022)
So I want to do something like this:
I have a "measure1" that spits out a date based on some calculation. measure1 is a date (i.e 13-Nov-21)
SUM(Sales) all rows between 03-2021 and 02-2022 based on "measure1"
So if measure1 is 13-Nov-21 so I want to SUM(Sales) all dates between 03-2021 and 02-2022.
Solved! Go to Solution.
Hi @samnaw ,
Create new columns to transform the date.
r12from column=
var _rightyear=RIGHT(('Table'[r12from]),4)
var _leftmonth=LEFT(('Table'[r12from]),1)
var _date=_rightyear&"/"&_leftmonth&"/"&1
return _date
r12to column=
var _rightyear=RIGHT(('Table'[r12to]),4)
var _leftmonth=LEFT(('Table'[r12to]),1)
var _date=_rightyear&"/"&_leftmonth&"/"&1
return _date
Then create a measure like below:
measure =
VAR _1 =
CALCULATE (
SUM ( table[sales] ),
FILTER (
ALL ( table ),
table[date] <= SELECTEDVALUE ( table[r12from column] )
&& table[date] >= SELECTEDVALUE ( table[r12to] )
)
)
RETURN
IF ( measure1 = DATE ( 2021, 11, 21 ), _1, BLANK () )
Best Regards,
Jay
Hi @samnaw ,
Create new columns to transform the date.
r12from column=
var _rightyear=RIGHT(('Table'[r12from]),4)
var _leftmonth=LEFT(('Table'[r12from]),1)
var _date=_rightyear&"/"&_leftmonth&"/"&1
return _date
r12to column=
var _rightyear=RIGHT(('Table'[r12to]),4)
var _leftmonth=LEFT(('Table'[r12to]),1)
var _date=_rightyear&"/"&_leftmonth&"/"&1
return _date
Then create a measure like below:
measure =
VAR _1 =
CALCULATE (
SUM ( table[sales] ),
FILTER (
ALL ( table ),
table[date] <= SELECTEDVALUE ( table[r12from column] )
&& table[date] >= SELECTEDVALUE ( table[r12to] )
)
)
RETURN
IF ( measure1 = DATE ( 2021, 11, 21 ), _1, BLANK () )
Best Regards,
Jay
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 |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |