Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello.
I need to calculate the following formula, but based on specific months (ie April to September 2021, 2022)
x = number + number + sum(data in a table). I think I need to use DATESINPERIOD. but I don`t know how to select the months.
I have a date table (01/01/2019 to present, I will need April to Sept 21 and 22)
How could I do it?
Solved! Go to Solution.
Hi @Alexandra_B ,
According to your description, I create a sample.
Here's my solution, create a measure.
X =
VAR _Sum =
CALCULATE (
SUM ( 'BB_EGLF_CDD_15 5C_till_june22'[CDD 15.5] ),
FILTER (
ALL ( 'BB_EGLF_CDD_15 5C_till_june22' ),
MONTH ( 'BB_EGLF_CDD_15 5C_till_june22'[Month] )
IN { 4, 5, 6, 7, 8, 9 }
&& YEAR ( 'BB_EGLF_CDD_15 5C_till_june22'[Month] ) IN { 2019, 2020, 2021, 2022 }
)
)
RETURN
42180.2942 + 68.8235277 * _Sum
Here I only return the sum and get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Hi @Alexandra_B ,
According to your description, I create a sample.
Here's my solution, create a measure.
X =
VAR _Sum =
CALCULATE (
SUM ( 'BB_EGLF_CDD_15 5C_till_june22'[CDD 15.5] ),
FILTER (
ALL ( 'BB_EGLF_CDD_15 5C_till_june22' ),
MONTH ( 'BB_EGLF_CDD_15 5C_till_june22'[Month] )
IN { 4, 5, 6, 7, 8, 9 }
&& YEAR ( 'BB_EGLF_CDD_15 5C_till_june22'[Month] ) IN { 2019, 2020, 2021, 2022 }
)
)
RETURN
42180.2942 + 68.8235277 * _Sum
Here I only return the sum and get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Thank you 🙂
@Alexandra_B Try this
var a = calculate ( sum (data in table ) , DATESBETWEEN ( your date column , Start date , End date))
return number + number + a
Hello, @Anonymous .
Thank you for your reply.
I have tried, but I get the following error.
The syntax for 'return' is incorrect.
(DAX(CALCULATE (SUM( 'BB_EGLF_CDD_15 5C_till_june22'[CDD 15.5] ), DATESBETWEEN('BB_EGLF_CDD_15 5C_till_june22'[Month], DATE(2021,04,01), DATE(2021,09,30)))return "42180.2942" + "68.8235277" * 'a')).
I am doing it wrong?
Create a measure
x =
var a =CALCULATE (SUM( 'BB_EGLF_CDD_15 5C_till_june22'[CDD 15.5] ),
DATESBETWEEN('BB_EGLF_CDD_15 5C_till_june22'[Month],
DATE(2021,04,01),
DATE(2021,09,30))
return 42180.2942 + 68.8235277 * a
What if I need for all the years same months , 2019 - 2022? That means I cannot use DATESBETWEEN for it... 😞
yes correct, Datesbetween wont work there.
can you show what exactly you are trying to achive.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
104 | |
69 | |
48 | |
41 | |
34 |
User | Count |
---|---|
164 | |
112 | |
62 | |
54 | |
38 |