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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
MNGoodyear
Frequent Visitor

filtering using calculated fields

 

I have sales order data by account/year/commodity/rep /order reference etc... 

 

I want to create an interactive enquiry where the user can ask quesitons of the data. For example

 

Using the below basic table, show me all accounts where sales of category B are 0/Null in 2018 but sales of category A are > 0 in 2018, in this example i would expect to return account 1 and account 2

 

AccountCategoryYearQty
1A2017100
1B201750
1A2018150
2A201875
3A201810
3B201850

 

I have created measures to summarise the qty by category  for each year using filter parematers such as :

 

Sales Cat A 18 = CALCULATE(sum('Report 1'[Qty]),FILTER('Report 1',[Category] = "A"),FILTER('Report 1','Report 1'[Year]=2018))

 

But i cannot work out how to apply the filtering 

 

Help

 

Thanks

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@MNGoodyear

 

If I understand correctly you want a sort of dynamic measure, with dynamic code, that calculates different things depending on what is selected on slicers.

I would suggest using harvester measures. You create a separate, unconnected  table for each of the variables you want to play with, like Category, Year, and if you need it, Type of comparison (>0, =0)


With the harvester measure you capture what's been selected and 

[Sales1]=CALCULATE(SUM(Report1[Qty]), Report1[Category]=[Harvested Category1]; Report1[Year]=[Harvested Year1])

[Sales2]=CALCULATE(SUM(Report1[Qty]), Report1[Category]=[Harvested Category2]; Report1[Year]=[Harvested Year2])

 

Table= FILTER(ALL(Report1[Account]), [Sales1] > 0 && [Sales2] =0)

 

You could follow a similar approach to select the comparison ">0", "=0", etc.

 

 

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

Hi @MNGoodyear

 

How about creating a table

 

Table= FILTER(ALL(Report1[Account]), [Sales A] > 0 && [Sales B] =0)

 

with

[Sales A]=CALCULATE(SUM(Report1[Qty]), Report1[Category]="A"))

[Sales B]=CALCULATE(SUM(Report1[Qty]), Report1[Category]="B"))

 

You can set the year on a slicer

hi the objective is to categorise a number of scenarios, for example adding sliders for :

 

Category A 2017

Category B 2017

Category A 2018

Category B 2018

 

so the user can interactively apply different types of filters to the data which i dont think the solution will allow

AlB
Community Champion
Community Champion

@MNGoodyear

 

If I understand correctly you want a sort of dynamic measure, with dynamic code, that calculates different things depending on what is selected on slicers.

I would suggest using harvester measures. You create a separate, unconnected  table for each of the variables you want to play with, like Category, Year, and if you need it, Type of comparison (>0, =0)


With the harvester measure you capture what's been selected and 

[Sales1]=CALCULATE(SUM(Report1[Qty]), Report1[Category]=[Harvested Category1]; Report1[Year]=[Harvested Year1])

[Sales2]=CALCULATE(SUM(Report1[Qty]), Report1[Category]=[Harvested Category2]; Report1[Year]=[Harvested Year2])

 

Table= FILTER(ALL(Report1[Account]), [Sales1] > 0 && [Sales2] =0)

 

You could follow a similar approach to select the comparison ">0", "=0", etc.

 

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.