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

Filter ALL but maintain period from slicer

I have a report where I want to calculate the average of a value within the period set by slicer, and compare it with current value. 

 

NameTripValueDate
ICE11701.01.2019
ICE26502.01.2019
GOT19003.01.2019
ICE34004.01.2019
GOT26505.01.2019
ICE46306.01.2019
    
  51,5Average ICE
  65Average GOT

 

So I want to calculate average Value for each Name within the chosen period and compare with value of current/chosen Trip. 

 

Example: 

Period = 04.01.2019 - 06.01.2019 

I choose ICE Trip 4 which got Value 63

In addition I want to calculate the average within the set period for ICE = 51,5

 

I have used ALL(Trip) to return all Trips - but I only want all trips within the period. 

How can I do that? 

 

 

4 REPLIES 4
amitchandak
Super User
Super User

Please create a date dimension table and join it with a date.  That will make it a different table and you should able to work with all(trip)

https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions

 

For others, you can have the filter in calculate

 

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Anonymous
Not applicable

Thanks amitchandak. 

 

Date table (which is set as date table) is now connected to the date column in my table. 

 

When I added the date slicer I had to add an ALL(Date) filter in my CALCULATE otherwise it would calculate basis the selected Trip only. 

However by filtering by ALL(Date) I get all dates, and not just the dates in the relevant period. 

(I get the same average no matter what period I choose)

 

So how can I solve that..? 

 

This is my current measure: 

 

Average Value =
VAR Selected_Name = SELECTEDVALUE(Table[Name]; 0)

RETURN

IF(COUNT(Table[Name]) > 1; 0;

CALCULATE(
AVERAGE(Table[Value]);
Table[Name] = Selected_Name;
ALL(Table[Trip]);
ALL(Table[Date]);
Table[Value] <> 0 )

 

This returns the average for the chosen Name, over all Trips - but also over all dates.. 

If I remove the ALL(Date), I will only get values for the chosen Trip. 

If possible please share a sample pbix file after removing sensitive information.
Thanks

Anonymous
Not applicable

I've been working on a report with non-sensitive data, and in that report the date filtering works.. 

It is built apparently identical and the measures are copy/paste to the new report. 

I have however removed many rows from the data table. 

 

This indicates there's some issue somewhere else. Perhaps some dates in the full data table? I will continue searching for an issue. 

 

I have shared the file anyway. 

https://drive.google.com/open?id=1v2kSnuATI-X4tWvROwIzKS0zdGykO29r 

 

The concept; 

Choose one voyage in the table visual. This shows the discharging rate in that port in a card visual - but also a card showing the average over all rows for that vessel and port, within the time period. The latter card/measure is the one that's creating problems.

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.