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
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 ) )

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
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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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