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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
kyinghfedex
Regular Visitor

Table Return Values Based on 2 Criteria(dates)

Im trying to create a dynamic table, that returns a value based on the slicer selection. In a scenario, I want to show what were the projected sales number from previous 4 weeks, to see the change in numbers. Slicer selection = Current date in table

 

The return value is also based on the slicer selection, and the date version. And the data will change based on the slicer, while the rows in the table is essentially D-7, D-14, D-21, D-28 (previous weeks). Seems quite a complicated task to do in PBI.

kyinghfedex_0-1717148779990.png

 

I tried using SELECTEDVALUE, but I think it didnt work. Im attaching a saple of data and what it supposed to look and work as a dashboard in excel

 

Uploaded a sample of the file

https://docs.google.com/spreadsheets/d/1Qmc8ruUyi5QmDd1mB6pfk-8o64VJ9OJx/edit?usp=sharing&ouid=10916...

1 ACCEPTED SOLUTION
Bmejia
Solution Specialist
Solution Specialist

Create a switch measure as below, 

Days =

SWITCH(TRUE(),
(SELECTEDVALUE(WeekData[Sales Week]))=(SELECTEDVALUE(WeekData[Input Week])),"Current Week",
(SELECTEDVALUE(WeekData[Sales Week])-7)=(SELECTEDVALUE(WeekData[Input Week])),"D-7",
(SELECTEDVALUE(WeekData[Sales Week])-14)=(SELECTEDVALUE(WeekData[Input Week])),"D-14",
(SELECTEDVALUE(WeekData[Sales Week])-21)=(SELECTEDVALUE(WeekData[Input Week])),"D-21",
(SELECTEDVALUE(WeekData[Sales Week])-28)=(SELECTEDVALUE(WeekData[Input Week])),"D-28",0)
 
Add your fields to the matrix table included the Days measure,  Then use the filter pane and filter days on  "is Not 0" so only shows 5 weeks worth of data from the Sales Week day selected.  if Days column is not sort correctly use the input weekly to sort the data.
 
Bmejia_1-1717184105189.png

 


 

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar problem in the attached PBI files.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Bmejia
Solution Specialist
Solution Specialist

Create a switch measure as below, 

Days =

SWITCH(TRUE(),
(SELECTEDVALUE(WeekData[Sales Week]))=(SELECTEDVALUE(WeekData[Input Week])),"Current Week",
(SELECTEDVALUE(WeekData[Sales Week])-7)=(SELECTEDVALUE(WeekData[Input Week])),"D-7",
(SELECTEDVALUE(WeekData[Sales Week])-14)=(SELECTEDVALUE(WeekData[Input Week])),"D-14",
(SELECTEDVALUE(WeekData[Sales Week])-21)=(SELECTEDVALUE(WeekData[Input Week])),"D-21",
(SELECTEDVALUE(WeekData[Sales Week])-28)=(SELECTEDVALUE(WeekData[Input Week])),"D-28",0)
 
Add your fields to the matrix table included the Days measure,  Then use the filter pane and filter days on  "is Not 0" so only shows 5 weeks worth of data from the Sales Week day selected.  if Days column is not sort correctly use the input weekly to sort the data.
 
Bmejia_1-1717184105189.png

 


 

Hi Bmejia, could you share your PBI file as well? Im having difficulties in getting the correct format to show the table

 

Sorry, I am not able to upload files like others in the forum

Maybe this will make more sense. 

 

1st just add a table and add your fields Input Week, Project Sales. (This will show everything)

2nd Add a dropdown filter and add the Sales Week field

3rd Create measure above and add to table

4th go to the filter pane and look for days and filter by “is not” 0 (as print screen above).

5th  you should only be able to see the date ranges 7,14,28 etc.. every time you filter by Sales Week selected.

That worked a treat. Thanks so much!

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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