I have a list of customers that I wish to categorize based on two criteria: Share of total income and average time from due date to payment date.
I have a table with customer transactions that I can use to calculate these two criteria.
The solution I currently have is to use calculated columns in the customer table:
Sum of invoiced amount per customer/Total sum all customers = Share of total income
Average number of days per customer
I then use IF-functions to categorize these metrics into Big/Medium/Small customers, and Good/Medium/Bad payers.
Next I use a Matrix visualization to see number of customers for each category (Big customer/Good payer, Small Customer/Medium payer, and so on).
The problem I get is that the outcome of this is static, and they doesn't change if I use slicers to get only transactions from one year, or for only one of our companies.
Can I instead use measures for this, and get a dynamic Matrix visualization?
You need to use measures for this. It is a common pattern known as dynamic segmentation. You can read how to implement it here: https://www.daxpatterns.com/dynamic-segmentation/
Related
I am trying to put together a report in which I have 2 card visuals (for two separate years) that show the total number of stores that sell at least an average N of products each month.
The measure I tried making in Dax finds average sold by year, but would I also need to take store into account there within the measure?
Either way the Card visual wont let me filter by my measure
Here is a very simplified version of the data: Sample Dummy table
Essentially wanting to show one card that shows the number of stores that are averaging at least 2 sales per month so far this year. And one that shows the same metric to this point in the prior year
I also have my table linked to a calendar table
I got an online campaign data, and there is an issue that the 'budget' for each day/campaign is the same but each time a campaign happens the budget repeats.
for example:
I want to build a table, that shows the avg budget of each campaign for these two days, as well as the total (also avg) at the bottom, like this:
Create a measure that calculates the Average() of the budget column.
Then create a visualisation (table or matrix) and use the campaign field along with the measure.
I have a horizontal bar visual where I’ve plotted the users with the highest sales.
It is "user name" vs "SUM(sales)" (user names and sales are in two different tables).
I’ve also used a filter as I only want to see users with SUM(sales)>1000€.
Now, on this page I want to put other visuals so that I can see information about this group of users, such as:
How many users are there?
What's the average age?
How many men and women?
and so on...
However, if I use a page level filter on sales, I can only filter a single sale value and not the sum for the user.
How can I filter the page based on a user’s total sales?
You could create a calculated column for a user’s total sales in your username table and then filter based on that.
Total Sales = CALCULATE(SUM(Table2[sales]))
There’re also solutions utilizing GROUP BY if you prefer that.
I need to build a formula in DAX that will show the number of customers who purchased again after their initial purchase, broken out by Product. I have a standard data warehouse with a Order Placed fact table, a Customer dimension table, and a Product dimension table. I am able to find the number of customers who purchased each product on their initial purchase by using this formula:
First Purchase Customer Count = CALCULATE(DISTINCTCOUNT(Demand[CustomerKey]),Demand[Customer Order Sequence Number] = 1)
My visual is a table with the Product as the only attribute, so this first formula is being calculated per Product. The next formula needs to count the number of customers who bought a second time, regardless of what Product they purchased that second time, but it should only include customers who purchased the current Product the first time. I have successfully created this formula to do it, but it usually errors out on the 1M row limit unless I filter the Product by subcategory.
Rebuyer Count = COUNTROWS(INTERSECT(SUMMARIZE(FILTER(Demand,Demand[Customer Order Sequence Number] = 1),[CustomerKey]),SUMMARIZE(CALCULATETABLE(FILTER(Demand,Demand[Customer Order Sequence Number] = 2),all('Product')),[CustomerKey])))
How can I improve this formula so it will run without bombing?
Old question, but on the off-chance that this is still an issue for you, have you reviewed the New and Returning Customers pattern on DaxPatterns.com? http://www.daxpatterns.com/new-and-returning-customers/
Your returning customers solution is creating a table of first-time customers, and then a table of second-time customers, and then joining those two tables together to count the number of first-time customers who are also a second-time customer.
The DaxPatterns solution is slightly different. Rather than calculating 2 potentially large tables of customers on the fly and then joining them, it is counting existing customers who have made a prior purchase.
You would need to adapt their solution to meet your requirements. They have a concept of Absolute Returning Customers (meaning the customer's first-purchase was for any product, and their second purchase was for the specific product you care about). You want the reverse of that (the customer's first-purchase was for a specific product, and their second purchase can be anything).
Overall, however, you'll have less bombing out if you start from a single list of first-time customers and filter out the customers you don't want (i.e. who never bought again) vs. compiling 2 separate lists of customers and intersecting them.
(It's the difference between letting everyone into the theatre, then throwing out everyone without a ticket, vs. checking tickets at the door and only letting people with a ticket in).
I am working on a report that has data by month. I have created a measure that will calculate a cost per unit which divides the sum of dollars by the sum of production volume for the selected month(s):
Wtd Avg = SUM('GLData - Excel'[Amount])/SUM('GLData - Excel'[Production])
This works well and gives me the weighted average that I need per report category regardless of if I have one or multiple months selected. This actual and budget data is displayed below:
If you take time to total the actual costs you get $3.180. Where I am running into trouble is a measure to sum up to that total for a visual (This visual does not total sadly). Basically I need to sum the aggregated values that we see above. If I use the Wtd Avg measure I get the average for the total data set, or .53. I have attempted another measure, but am not coming up with the correct answer:
Total Per Unit Cost = sumX('GLData - Excel','GLData - Excel'[Wtd Avg])/DISTINCTCOUNT('GLData - Excel'[Date])
We see here I return $3.186. It is close, but it is not aggregating the right way to get exactly the $3.180:
My Total Per Unit Cost formula is off. Really I am simply interested in a measure to sum the post aggregated Wtd Avg measure we see in the first graph and total to $3.180 in this example.
Here is my data table:
As you probably know already, this is happening because measures are dynamic - if you are not grouping by a dimension, they will compute based on the overall table. What you want to do is to force a grouping on your categories, and then compute the sum of the measure for each category.
There are 2 ways to do this. One way is to create a new table in Power BI (Modeling tab -> New Table), and then use a SUMMARIZE() calculation similar to this one to define that table:
SUMMARIZE('GLData - Excel',[Category],[Month],[Actual/Budget],"Wtd Avg",[Wtd Avg])
Unfortunately I do not know your exact column names, so you will need to adjust this calculation to your context. Once your new table is created, you can use the values from that table to create your aggregate visual - in order to get the slicers to work, you may need to join this new table to your original table through the "Manage Relationships" option.
The second way to do this is via the same calculation, but without having to create a new table. This may be less of a hassle. Create a measure like this:
SUMX(SUMMARIZE('GLData - Excel',[Category],[Month],[Actual/Budget],"Wtd Avg",[Wtd Avg]),[Wtd Avg])
If this does not solve your issue, go ahead and show me a screenshot of your table and I may be able to help further.