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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
x-datita
Frequent Visitor

How to avoid weeks being cut short by the month?

Hello!

 

I would like to know if it is possible to avoid having duplicate weeks, by taking the data at a granularity level from month to week?

 

For example, in the graph it shows week 5 in both January and February, and it looks like sales fell in the last week of January, when they did not. The x-axis is Month and week

xdatita_0-1707765968423.png

 

The dax I use is a calculation of sales for the current year:
Sales curr year = CALCULATE ([Sales], FILTER ( 'Calendar', 'Calendar'[Offset Year] = 0 ))

 

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @x-datita 

 

Please try this:

I create a set of sample:

vzhengdxumsft_0-1707793793609.png

Then create a measure:

Measure = 
	VAR _currentweek = MAX('Table (2)'[week])
	RETURN
		CALCULATE(
			SUM('Table (2)'[value]),
			FILTER(
				ALLSELECTED('Table (2)'),
				'Table (2)'[week] = _currentweek
			)
		)

The result is as follow:

vzhengdxumsft_1-1707793858759.png

Use the all(), allselected(), allexcept(), and removefilter() functions to remove unwanted filtering effects.
Here's a blog about contextual filtering

Understand the Filter Context and How to Control i... - Microsoft Fabric Community

 

Best Regards,

Zhengdong Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhengdxu-msft
Community Support
Community Support

Hi @x-datita 

 

Please try this:

I create a set of sample:

vzhengdxumsft_0-1707793793609.png

Then create a measure:

Measure = 
	VAR _currentweek = MAX('Table (2)'[week])
	RETURN
		CALCULATE(
			SUM('Table (2)'[value]),
			FILTER(
				ALLSELECTED('Table (2)'),
				'Table (2)'[week] = _currentweek
			)
		)

The result is as follow:

vzhengdxumsft_1-1707793858759.png

Use the all(), allselected(), allexcept(), and removefilter() functions to remove unwanted filtering effects.
Here's a blog about contextual filtering

Understand the Filter Context and How to Control i... - Microsoft Fabric Community

 

Best Regards,

Zhengdong Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much it works great!!

 

An additional question, do you know if it is possible to take week 52 as the first week in the display, only when it appears in January?

 

xdatita_0-1708015983243.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.