The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I need to create a measure to add values for the last week, but within the same month.
I made the measurement below, but it is taking from 11/29/2021 until 12/05/2021.
I need her to return the week within the current month (12/01/2021 to 12/05/2021)
Can you help me?
Solved! Go to Solution.
Hi @RSSILVA_22
Please try this Measure.
gross_na_semana =
VAR _selectedDate =
MAX ( tb_gross_agencias_correios[data_atendimento] )
VAR _endOfWeekDate =
_selectedDate + 7
- WEEKDAY ( _selectedDate, 2 )
VAR lastMonday =
CALCULATE (
MIN( tb_gross_agencias_correios[data_atendimento] ),
FILTER (
ALL ( tb_gross_agencias_correios[data_atendimento] ),
tb_gross_agencias_correios[data_atendimento] <= _selecteddate
&& tb_gross_agencias_correios[data_atendimento]>_endOfWeekDate-7
&& MONTH ( tb_gross_agencias_correios[data_atendimento] ) = MONTH ( _selectedDate )
)
)
RETURN
CALCULATE (
DIVIDE ( SUM ( tb_gross_agencias_correios[qtda] ), [Total DUs Parcial], 0 ),
tb_gross_agencias_correios[servico] = "Gross Adds",
tb_gross_agencias_correios[status_atendimento] = "F",
FILTER (
ALL ( tb_gross_agencias_correios[data_atendimento] ),
tb_gross_agencias_correios[data_atendimento] <= _endOfWeekDate
&& tb_gross_agencias_correios[data_atendimento] >= lastMonday
)
)
Best Regards,
Community Support Team _ Caiyun
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If you still have problems on it or I misunderstand your needs, please feel free to let us know. Thanks a lot!
Hi @RSSILVA_22
Please try this Measure.
gross_na_semana =
VAR _selectedDate =
MAX ( tb_gross_agencias_correios[data_atendimento] )
VAR _endOfWeekDate =
_selectedDate + 7
- WEEKDAY ( _selectedDate, 2 )
VAR lastMonday =
CALCULATE (
MIN( tb_gross_agencias_correios[data_atendimento] ),
FILTER (
ALL ( tb_gross_agencias_correios[data_atendimento] ),
tb_gross_agencias_correios[data_atendimento] <= _selecteddate
&& tb_gross_agencias_correios[data_atendimento]>_endOfWeekDate-7
&& MONTH ( tb_gross_agencias_correios[data_atendimento] ) = MONTH ( _selectedDate )
)
)
RETURN
CALCULATE (
DIVIDE ( SUM ( tb_gross_agencias_correios[qtda] ), [Total DUs Parcial], 0 ),
tb_gross_agencias_correios[servico] = "Gross Adds",
tb_gross_agencias_correios[status_atendimento] = "F",
FILTER (
ALL ( tb_gross_agencias_correios[data_atendimento] ),
tb_gross_agencias_correios[data_atendimento] <= _endOfWeekDate
&& tb_gross_agencias_correios[data_atendimento] >= lastMonday
)
)
Best Regards,
Community Support Team _ Caiyun
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If you still have problems on it or I misunderstand your needs, please feel free to let us know. Thanks a lot!
@RSSILVA_22 , Last week within same moth
Last Week =
var _max = maxx(allselected('Date'), 'Date'[Date])
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1 && eomonth('Date'[Date],0) - eomonth(_max,0) ))
But what will happen when this first week of month ?
new columns in date table
new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
Week = WEEKNUM([Date],2)
year Week = if('Date'[Week Number]<10,'Date'[Year]*10 & 'Date'[Week Number],'Date'[Year]&'Date'[Week Number])
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
User | Count |
---|---|
18 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
13 | |
12 | |
9 | |
8 |