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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
carade9
New Member

How to show 'last week data of previous month' after selecting this month filter

file:     bi

hi guys please help me i cant visual last week of previous month (e.g. W4 or W5) after select this month

peoplehelpme_0-1711073035878.png

peoplehelpme_2-1711073091279.png

  

peoplehelpme_3-1711073147377.png

peoplehelpme_4-1711073205829.png

when i select"Aug" &"W1" -> on the "Last Week" table it should show Energy dar 138 not a blank

peoplehelpme_5-1711073237374.png

  above code is a filter for last week 

peoplehelpme_6-1711073301953.png

peoplehelpme_7-1711073328303.png

these two above picture is hown data 

ps. i attach file in link pi bi

1 ACCEPTED SOLUTION

Hi @peoplehelpme ,

 

I suggest you to try an unrelated table and measures to filter your visuals.

DimDate = 
SUMMARIZE (
    'Table',
    [Date],
    [Week num from 2020],
    [Week num in month],
    "Year", YEAR ( [Date] ),
    "Month", FORMAT ( [Date], "MMM" ),
    "MonthSort", MONTH ( [Date] )
)

Measure:

Current Week = 
VAR _DAYLIST = VALUES(DimDate[Date])
RETURN
IF(MAX('Table'[Date]) IN _DAYLIST,1,0)
Last Week = 
VAR _SELECTWEEKNUM = SELECTEDVALUE(DimDate[Week num from 2020])
RETURN
IF(MAX('Table'[Week num from 2020]) = _SELECTWEEKNUM -1 ,1,0)

Add measure into visual level filter to filter two table visuals.

Result is as below.

vrzhoumsft_0-1711353890220.png

vrzhoumsft_1-1711353908746.png

 

Best Regards,
Rico Zhou

 

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

3 REPLIES 3
peoplehelpme
Helper I
Helper I

ok sir, thank you for your time

1) i want to show last week data and this week data ; here is example

DateItemWeek num in monthWeek num from 2020
31Dec2020AW552
1Jan2021BW153
2Jan2021CW153
3Jan2021DW153
4Jan2021EW153
5Jan2021FW153
6Jan2021GW153
7Jan2021HW153
8Jan2021IW254
9Jan2021JW254
10Jan2021KW254

 

i create filter "Week num in month", "Month" (extract from 'Date') , "Year"(extract from 'Date')
this is scenario 

1)

i choose "W2" and "Jan" and "2021" ->

result of last week are "B","C",...,"H" . 

result of this week are "I","J","K" 

2) 

i choose "W1" and "Jan" and "2021" ->

result of last week are "A"

result of this week are "B","C",...,"H"

Hi @peoplehelpme ,

 

I suggest you to try an unrelated table and measures to filter your visuals.

DimDate = 
SUMMARIZE (
    'Table',
    [Date],
    [Week num from 2020],
    [Week num in month],
    "Year", YEAR ( [Date] ),
    "Month", FORMAT ( [Date], "MMM" ),
    "MonthSort", MONTH ( [Date] )
)

Measure:

Current Week = 
VAR _DAYLIST = VALUES(DimDate[Date])
RETURN
IF(MAX('Table'[Date]) IN _DAYLIST,1,0)
Last Week = 
VAR _SELECTWEEKNUM = SELECTEDVALUE(DimDate[Week num from 2020])
RETURN
IF(MAX('Table'[Week num from 2020]) = _SELECTWEEKNUM -1 ,1,0)

Add measure into visual level filter to filter two table visuals.

Result is as below.

vrzhoumsft_0-1711353890220.png

vrzhoumsft_1-1711353908746.png

 

Best Regards,
Rico Zhou

 

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

 

 

Greg_Deckler
Super User
Super User

@carade9 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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