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
Cotter2000
Frequent Visitor

Revenue by Customer & Year, Filtered Dynamically by additional field

Hi everyone,

 

New to Dax here.  I have four fields:

 

Customer, Product Format, Price, Transaction Year

 

For each customer AND transaction Year, I'm trying to calculate a sum of Price for any year my end user filters on.  For example, for a particular customer in year 2015, I want the revenue bucket to be as follows:

 

Product FormatPriceRevenue Bucket
Format A$1307. $125+
Format B$427. $125+
Format B$537. $125+
Format C$1007. $125+

 

I've gotten that far by creating the following two fields:

 

RevenueSum = CALCULATE(SUM('Purchasers'[Price]),ALLEXCEPT('Purchasers','Purchasers'[Customer],'Purchasers'[Transaction Year]))

 

Revenue Bucket = IF([RevenueSum]<.01,"1. $0",IF([RevenueSum]<=25,"2. $1-$25",IF([RevenueSum]<=50,"3. $26-$50",IF([RevenueSum]<=75,"4. $51-$75",IF([RevenueSum]<=100,"5. $76-$100",IF([RevenueSum]<125,"6. $101-$124","7. $125+"))))))

 

However, I want RevenueSum to dynamically change whenever my users filter on one or more Product Formats.  For example, if my end user filters for Format B in their Power BI dashboard, I want RevenueSum to recalculate to $95 and the Revenue Bucket to become $76-$100.   If they select Formats A & B, it would recalculate to $225 and Revenue Bucket would go back to "$125+."

Right now, the revenue bucket remains static at "$125+".  Is there any way to get my RevenueSum measure to dynamically change based on what the end user is filtering for on Product Format?

If I add ProductFormat to my list of ALLEXCEPT I get sums for every customer/year/format but I don't want that.  I want it to roll up by year for whatever combination of product format my end users choose.

 

Thanks!

10 REPLIES 10
Cotter2000
Frequent Visitor

Thank you both for telling me about Banding.  It might be the solution but I'm having trouble making it work.  What I want to do is always keep the filters on customer and transaction year.   In other words, I want to always sum by those fields, and then let my end user change those sums with additional filtering on Product Format, changing the bands a particular customer falls into dynamically.  Here is the table I have created based on some of your suggestions:

 

CustomerYearFormatRevenueRevenueSumRevenueBandGroup
12015Format A130325>$125
12015Format B42325>$125
12015Format B53325>$125
12015Format C100325>$125

 

However, when I filter further by Product Format B, like my end user would, I get the following:

 

CustomerYearFormatRevenueRevenueSumRevenueBandGroup
      
12015Format B42325>$125
12015Format B53325>$125
      

 

What I want is this:

 

CustomerYearFormatRevenueRevenueSumRevenueBandGroup
      
12015Format B4295$76-$100
12015Format B5395$76-$100
      

 

In this way, the end user can see how the number of customers in each bucket would change if they eliminated certain product formats from the analysis.  

 

It seems like RevenueSum is my problem.  That equation doesn't change dynamically and therefore doesn't force the bands to change.  It calculates a static sum by customer and year.  Here is the formula. 

RevenueSum = CALCULATE(SUM('Purchasers'[Price]),ALLEXCEPT('Purchasers','Purchasers'[Customer],'Purchasers'[Transaction Year]))

 

How do I get that Sum to then change with additional filters?  In Tableau, this would be called a 'Context filter' which would be applied before the static sum is calculated.  I just can't figure out the equivalent in Power BI.

Thanks for all your help so far.  I really appreciate it. 

@Cotter2000,

Directly create your measures using the following DAX, then check if you get expected result.

RevenueSum = SUM('Purchasers'[Price])
Revenue Bucket = IF([RevenueSum]<.01,"1. $0",IF([RevenueSum]<=25,"2. $1-$25",IF([RevenueSum]<=50,"3. $26-$50",IF([RevenueSum]<=75,"4. $51-$75",IF([RevenueSum]<=100,"5. $76-$100",IF([RevenueSum]<125,"6. $101-$124","7. $125+"))))))

1.PNG


Regards,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft

Hi Lydia,

 

Thanks for your response. 

 

That is actually where I had started.  Your equation matches my first attempt.  Since it is dynamically summing up Price with no other filters placed on it, it simply copies the revenue from each Product Format/Year/Customer and it assigns it to that Bucket. 

 

CustomerYearFormatRevenueRevenueSumRevenue Bucket
12015Format A1301307. >$125
12015Format B4242.43. $26-$50
12015Format B53534. $51-$75
12015Format C1001005. $76-$100

 

I'm trying to get the Sum to fluctuate as I pick different product formats, but never fluctuate beyond the boundaries of Year and Customer.  If I looked at 10 customers, and I isolated different product formats, it would assign each customer one and only one Revenue Bucket, based on only the Product Formats I've isolated. 

@Cotter2000,

Would you mind sharing me all the raw data of your table and post expected result here?

Regards,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yuezhe-msft,

 

I can't send actual data, but I have faked some data to show you what I am after.  Here is the table:

 

CustomerYearFormatRevenue
12015A130
12015B42
12015B53
12015C100
12016A200
22015A20
22015D30
22015E50
22016D50
32015A100
32015A200
32015B50
32016B60
32016B80

 

I want to sum revenue and count people by revenue bucket.  I add the following two fields to Power BI:

 

RevenueSum = CALCULATE(SUM(Sheet1[Revenue]),ALLEXCEPT(Sheet1,Sheet1[Customer],Sheet1[Year]))

 

Revenue Bucket = IF([RevenueSum]<.01,"1. $0",IF([RevenueSum]<=25,"2. $1-$25",IF([RevenueSum]<=50,"3. $26-$50",IF([RevenueSum]<=75,"4. $51-$75",IF([RevenueSum]<=100,"5. $76-$100",IF([RevenueSum]<124,"6. $101-$125","7. >$125"))))))

 

I then can use the buckets to show revenue and counts of unique customers.  But when I then further filter on Product Format, the amount of revenue does not change accordingly.  

 

Correct - prior to format filterCorrect - prior to format filterFormat Filter applied, no longer correctFormat Filter applied, no longer correct

 

When I format for only Product Format B, it should show me no revenue, because no customer in 2015 on their own has $125+ revenue within Format B. 

 

Let me know what you think - thanks!

 

Hi @Cotter2000

 

Have a look at my blog post, where I explain how to use Dynamic Banding across the entire dataset.

This might be what you are looking for to achieve your outcome.

 

Power BI – Dynamic Banding across all fields





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Hi @GilbertQ

 

Thanks for the link.  I read through your post and tried what you suggested.  However, if I want to use the Bands on my X or Y axis to show total revenue per band, can I do that using your approach?  The 'Amount Bands' is a measure and I can't get that to work in the Axis portion of a chart.  I tried it as a Column instead but that didn't work either. 

 

Thanks for any help.

Hi @Cotter2000

 

The way that I implemented it was to use the dynamic banding as a measure. I would then use any of my data in the columns to then be defined by the measures. In doing it this way it means that I can literally use any column and if I have my banding correct created it would drop then into each of the banding buckets.

 

And that also gives you the ability to then use any column on the X or Y Axis.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

GilbertQ
Super User
Super User

Hi there, depending on how you want to create your bands across your data, my blog post below might be able to assist to make it dynamic no matter which piece of data you choose to put it against.

 

https://gqbi.wordpress.com/2017/05/23/power-bi-dynamic-banding-across-all-fields/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

CheenuSing
Community Champion
Community Champion

Hi @Cotter2000

 

Try the following

 

1. Create a Band Table with the following columns

    RevenueBucket , MinValue, MaxValue

2. Example

   

RevenueGroupMinMax
0 - 30030
31 - 603160
61 - 906190
91 - 12091120
121 - 180121180
181 - 240181240
241 - 360241360
> 361361999999

 

This in only an example , the Revenue Group , Min and MAx Values will depend on the buckets you need.

 

3. Next  crete a measure of RevenueSum , which I presume you already have.

4. Create a measure called ReturnBandGroup

 

    ReturnBandGroup =
 CALCULATE(
    VALUES (RevenueBand[RevenueGroup]),
    FILTER (
        RevenueBand,
        [RevenueSum] >= RevenueBand[Min]
     && [RevenueSum] <= RevenueBand[Max]
    )
)

 

5. Now use this ReturnBandGroup measure in your reports.

 

If this solves your issue please accept it as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

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.