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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
debiesven
Frequent Visitor

Use date from and date to as axis on line chart

I have a status table with the following 5 fields:

  • Article number
  • Stock status (in stock, limited in stock, out of stock)
  • Date from
  • Date to
  • Is current

Based on these field I can manually check each moment in time that a product was in stock, limited in stock or out of stock. But now I want to put it into a line graph. So on 07/03/2022 we have 500 products in stock, 25 products limited in stock and 10 products out of stock. On day 2 (08/03/2022) we have 490 products in stock, 30 products limited in stock and 15 products out of stock. But I only have a from and a to date. Not the status date of 07/03/2022 or 08/03/2022 to use as the x-axis, but only the full period based on the from and to dates.

 

What is the best way to define what the status was on a particular day so it can easily be shown in a chart or graph.

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

What is the purpose/use of the "Is Current" column?  Share data in a format that can be pasted in an MS Excel workbook.


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

So create a simple flag for the latest results. It can be possible that a record has been deleted, so the date to is yesterday. But it is still the latest version, so the is current = true.

AllisonKennedy
Community Champion
Community Champion

There might be more efficient ways, but you could use a DAX approximate lookup with an unrelated date table: 

https://excelwithallison.blogspot.com/2020/06/dax-approximate-lookup.html

 

https://excelwithallison.blogspot.com/2021/09/power-bi-forecasting-with-irregular.html 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

I don't understand the explanation how to convert these periods into a daily state based on date. 

Anonymous
Not applicable

Hi @debiesven,

Did this flag field manually add on the data source side?

If that is the case, you can create a calculated column to compare with the date field with Dax today function and set a flag based on the result, these function results will be re-calculated every time the system date changes.

Flag =
IF ( Table[Date] = TODAY (), "Today" )

TODAY function (DAX) - DAX | Microsoft Docs
Regards,

Xiaoxin Sheng

Hi,

 

Thanks for your reply. The Is current flag is generated by our data warehouse. So that one is okay. My question is only about mapping the period to a certain date so I can plot it on a historical graph.

Anonymous
Not applicable

Hi @debiesven,

>>My question is only about mapping the period to a certain date so I can plot it on a historical graph.

It sounds like a common requirement about date value mapping to the date range defined by multiple fields. For this scenario you can refer to the following blog 'start date', 'end date' part or try to create a bridge table that expands the date range to map to the detailed date records:

Before You Post, Read This 

Solved: Spread revenue across period based on start and en... - Microsoft Power BI Community

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.