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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Adding a filter from filter pane into a formula

I have the following measure (below).     If I apply a filter context (using the filter pane), the values in my measures get filtered down to the proper amount.    But note that in the 3rd table, with no filter selected, it gives me gigantic (wrong) numbers.  

 

I would like to incorporate this field (seen in the filter area) into my Measure 7 formula, but I've tried adding it as a FILTER in my CALCUATE statement and that does not work.   Not sure what I am doing wrong.   

 

Tried this, but when I use this it makes the table go blank.  

CALCULATE(SUM(Flu_Snapshots[Actual Value]),FILTER(Flu_Snapshots,Flu_Snapshots[All Revenue Last Period]="Flu All Revenue Last Period"),FILTER(ALL(Dates[Date]), Dates[Date] = _lastDate))*-1

 

 

Current formula (shows correct values as long as the filter is manually selected).  


Measure 7 =

VAR _year = SELECTEDVALUE(Dates[Year])

VAR _month = SELECTEDVALUE(Dates[MonthName])

VAR _date = CALCULATE(MIN(Dates[Date]), FILTER(ALL(Dates), Dates[Year] = _year && Dates[MonthName] = _month))

VAR _lastDate = EOMONTH(_date,+0)+28



RETURN

CALCULATE(SUM(Flu_Snapshots[Actual Value]),FILTER(ALL(Dates[Date]), Dates[Date] = _lastDate))*-1

 
last period.png
 

 
4 REPLIES 4
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Would you please inform us more detailed information(such as your expected output and your sample data(by OneDrive for Business)) if possible? Then we will help you more correctly.

 

As far as the measure you gave us, I suggest you change the Measure7 to:

 

Measure 7 =

VAR _date = MIN(Dates[Date])

VAR _lastDate = EOMONTH(_date,+0)+28

RETURN

CALCULATE(SUM(Flu_Snapshots[Actual Value]),FILTER(ALL(Dates[Date]), Dates[Date] = _lastDate))*-1

 

Please do mask sensitive data before uploading.

 

Thanks for your understanding and support.

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

I will try to be even more specific to help get my post answered.   (Dedmon - thanks for your formula...it was simpler but still provided the same result as my Measure 7.   I called yours Measure 20 in my examples below).  

 

The table on the top left contains correct values.  You can see I have selected a filter (Flu All Revenue Last Period).   If I do NOT select this filter, I get the very large number shown in the table on the right, which is incorrect.  

 

My desired outcome is to incorporate this filter into my formula, rather than have to select it from the filter pane. 

 

 

 

 

 

last period.png

Hi @Anonymous ,

 

As I mentioned above, Because we do not know your data structure, it is difficult for us to help you effectively. We can only provide opinions and cannot give accurate answers  without test.

 

I suggest you try :

 

Measure 7 =

VAR _date = CALCULATE(MIN(Dates[Date]), ALL(Dates))

VAR _lastDate = EOMONTH(_date,+0)+28

RETURN

CALCULATE(SUM(Flu_Snapshots[Actual Value]),FILTER(ALL(Dates[Date]), Dates[Date] = _lastDate),

FILTER(ALL('Flu_Snapshots'),Flu_Snapshots[All Revenue Last Period]="Flu All Revenue Last Period"))*-1

 

Best Regards,

Dedmon Dai

Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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