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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Current Week versus Last Week Totals as a Bar Chart

redwood2021_0-1642074653487.png

Current Week 1/9/2022 - 1/15/2022

Last Week 1/2/2022 - 1/8/2022

 

Is it possible to show this as a bar chart ?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ~

 

I created a sample:

屏幕截图 2022-01-18 100302.jpg

Please try these measures:

 

Current Week = 
var __Today = TODAY()
var __WeekStartDate = __Today-WEEKDAY(__Today,1)+1
var __WeekEndDate = __WeekStartDate+6
return
CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),__WeekStartDate<='Table'[Closed] && __WeekEndDate>='Table'[Closed]))

 

 

Last Week = 
var __Today = TODAY()
var __WeekStartDate = __Today-WEEKDAY(__Today,1)-6
var __WeekEndDate = __WeekStartDate+6
return
CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),__WeekStartDate<='Table'[Closed] && __WeekEndDate>='Table'[Closed]))

 

create a table:

2020-08-19_09h24_01.png

屏幕截图 2022-01-18 094240.jpg

create a measure:

 

Measure Value = 
SWITCH(
SELECTEDVALUE('Table1'[order]),
1,[Current Week],
2,[Last Week]
)

 

Finally create a bar chart:

屏幕截图 2022-01-18 095449.jpg

屏幕截图 2022-01-17 183347.jpg

 

Hope it helps!

 

Best regards,

Community Support Team  Gao

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

 

View solution in original post

11 REPLIES 11
Ashish_Mathur
Super User
Super User

Hi,

The definition of a week itself is unclear.  For the year 2022, when will the week start from - January 1 or the first Monday of January?  If you can create a week number column in the Calendar table and share the download link of your PBI file, I can help.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

redwood2021_0-1642654159672.png

 

redwood2021_1-1642654224066.png

 

Hope this helps as I couldn't get the export form my desktop.

Anonymous
Not applicable

Hi~ @Anonymous 
Please check the data type of the Order column.If it is in Text format, change it to Whole number format.Then check  the bar chart.

屏幕截图 2022-01-20 142251.jpg

屏幕截图 2022-01-20 143021.jpg

If the problem is not solved, please provide the error information, it will help me to find the problem, thank you very much!

屏幕截图 2022-01-20 143259.jpg

Best regards,

Community Support Team  Gao

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

 

Anonymous
Not applicable

Here is the information you requested.

 

redwood2021_0-1642694690350.pngredwood2021_1-1642694774704.png

 

Anonymous
Not applicable

Hi~ @Anonymous 

The problem is because of the data type of the data.

Please contrast the data type of the measures and columns. Hope it helps.
This is my Test File

Best regards,

Community Support Team Gao

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

 




Anonymous
Not applicable

Hi @Anonymous ~

 

I created a sample:

屏幕截图 2022-01-18 100302.jpg

Please try these measures:

 

Current Week = 
var __Today = TODAY()
var __WeekStartDate = __Today-WEEKDAY(__Today,1)+1
var __WeekEndDate = __WeekStartDate+6
return
CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),__WeekStartDate<='Table'[Closed] && __WeekEndDate>='Table'[Closed]))

 

 

Last Week = 
var __Today = TODAY()
var __WeekStartDate = __Today-WEEKDAY(__Today,1)-6
var __WeekEndDate = __WeekStartDate+6
return
CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),__WeekStartDate<='Table'[Closed] && __WeekEndDate>='Table'[Closed]))

 

create a table:

2020-08-19_09h24_01.png

屏幕截图 2022-01-18 094240.jpg

create a measure:

 

Measure Value = 
SWITCH(
SELECTEDVALUE('Table1'[order]),
1,[Current Week],
2,[Last Week]
)

 

Finally create a bar chart:

屏幕截图 2022-01-18 095449.jpg

屏幕截图 2022-01-17 183347.jpg

 

Hope it helps!

 

Best regards,

Community Support Team  Gao

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

 

Anonymous
Not applicable

It look like the Closed (2022 Redwood Incidents) does not have Date associated with it. How can I resolve this issue?

 

redwood2021_0-1642642724882.png

 

amitchandak
Super User
Super User

@Anonymous , Create these new columns in date table

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],1)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Then try measures 

measures
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

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-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

 

 

Or share data in text format as suggested by @mh2587 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I'm getting the following error message:

 

redwood2021_0-1642136741045.png

 

mh2587
Super User
Super User

Can you please elaborate it further with expected out put and provide dummy data 


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Anonymous
Not applicable

redwood2021_0-1642075333895.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.