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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure to bring all dates till the filtered date

Hi,

 

I know it's quite common issue, but I still can't find the solution and there is a feeling that I'm doing something wrong.

My goal is to show in line graph qty dynamic by year and month. Main problem that there will be a filter of period necessary for other visuals. 

Problems:

  • I can't find the right DAX to be able to calculate all dates till the filtered period.
  • If I disable interactions between line chart and period filter, I get all dates, even those that shouldn't be in the graph.

 

For example, if I filtered 2020-10 period (2020 October), I need to see in the graph all dates till 2020-10-31

LV dates.JPG

I've tried to write a DAX formula that don't evaluate filter:

QTY visual = 
CALCULATE(
    SUM(INV[ INV_QTY ]), 
    FILTER(ALL('Date'[Date]), 'Date'[Date]<=MAX('Date'[Date]) ))

But it still shows just the period that is filtered.

Can you help me to figure out where I'm doing wrong?

 

The pbix example file is here: https://drive.google.com/file/d/1_Q_7-T9Cr6BrFdcydAnTOe9spcaJqbRv/view?usp=sharing

 

 

 

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

Hi, @Anonymous 

According to your description and sample picture, I think that you want to make the line chart show the data before or in the period you selected, right? You can try my steps:

  1. Create a calculated table for the Slicer:
Slicer =

SELECTCOLUMNS('Date',"Period",[Period],"Date",[Date])

Then make sure it doesn’t have a relationship with any tables, which is important:

v-robertq-msft_0-1611217578657.png

 

  1. Create a measure:
QTY visual1 =

var _selecteddate=MAX('Slicer'[Date])

return

IF(MAX('Date'[Date])<=_selecteddate,SUM(INV[ INV_QTY ]),BLANK())
  1. Go to the line chart and replace the measure in the “Value” with [QTY visual1], like this:

v-robertq-msft_1-1611217578667.png

 

And you can get what you want.

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description and sample picture, I think that you want to make the line chart show the data before or in the period you selected, right? You can try my steps:

  1. Create a calculated table for the Slicer:
Slicer =

SELECTCOLUMNS('Date',"Period",[Period],"Date",[Date])

Then make sure it doesn’t have a relationship with any tables, which is important:

v-robertq-msft_0-1611217578657.png

 

  1. Create a measure:
QTY visual1 =

var _selecteddate=MAX('Slicer'[Date])

return

IF(MAX('Date'[Date])<=_selecteddate,SUM(INV[ INV_QTY ]),BLANK())
  1. Go to the line chart and replace the measure in the “Value” with [QTY visual1], like this:

v-robertq-msft_1-1611217578667.png

 

And you can get what you want.

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

EricHulshof
Solution Sage
Solution Sage

I would make sure the filter does not interact with the linechart and use the selectedvalue from the filter in your DAX formula. 


Quality over Quantity


Did I answer your question? Mark my post as a solution!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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