cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tyler_rogers_ds
New Member

Filters not effecting my average calculated field.

Good morning Everyone,

 

I'm currently trying to create a KPI card that can be affected by multiple slicers:

Emailable: Not Emailable, Emailable

Current Salesplan (groups): a grouped field based on a field with multiple text values

 

I want to show last months average order frequency with this formula: (365 Avg # of Transactions is a measure field averaging a field full of integers)

Last Months Average = CALCULATE('Original Dataset'[365 Avg. # of Transactions],
FILTER('ShipTo Item Sales Master',MONTH('ShipTo Item Sales Master'[LastDatePurchased*]) = MONTH(TODAY())-1),
FILTER('ShipTo Item Sales Master',YEAR('ShipTo Item Sales Master'[LastDatePurchased*]) = IF(MONTH(TODAY())= 1,YEAR(TODAY())-1,YEAR(TODAY()))))
 
And two months ago using 
Two months Ago Only field 
Two Months Ago Only = IF(AND(MONTH('ShipTo Item Sales Master'[LastDatePurchased*])=MONTH(TODAY())-2,
MONTH('ShipTo Item Sales Master'[LastDatePurchased*])<>MONTH(TODAY())-1), TRUE, FALSE)
 
365 Avg. Transactions - Last Two Months Only = CALCULATE('Original Dataset'[365 Avg. # of Transactions],
FILTER('ShipTo Item Sales Master', 'ShipTo Item Sales Master'[Two Months Ago Only]=TRUE),
FILTER('ShipTo Item Sales Master',YEAR('ShipTo Item Sales Master'[LastDatePurchased*]) = IF(MONTH(TODAY())= 1,YEAR(TODAY())-1,YEAR(TODAY()))))
 
Any sort of guidance here will be beyond helpful. If additional information is needed, please inquire below.
 
Thanks again,
Tyler Rogers
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @tyler_rogers_ds,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

In addition, did you work with calculated columns? If that's the case, current power bi does not support creating dynamic calculated column/table base do filters. They work on different levels and you can't use child level to affect their parent.

Notice: the data level of power bi.

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @tyler_rogers_ds,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

In addition, did you work with calculated columns? If that's the case, current power bi does not support creating dynamic calculated column/table base do filters. They work on different levels and you can't use child level to affect their parent.

Notice: the data level of power bi.

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@tyler_rogers_ds , Not ver clear . you can use measure like this based on today . Assuming use of date table

 

This month Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),0) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Last month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

 

 

Use all if there is filter

 

 

This month Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),0) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )

Last month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1) //today()
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date] >= _min && 'Date'[Date] <=_max ) )



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Hi amitchan,

 

My KPI card is still not being affected by this formula you've given me. I am currently not making use of a date table.

 

Furthermore, I am searching for last month only and previous month from last month only. 

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors