Count of Orders per User ID within a time frame - powerbi

I have a table (Orders) that contains information about orders: User_id, Order_date and Order_price.
This table is linked to a date.table. What I would like to have is a measure that counts how many users made 1,2,3,4,5,.... orders. Basically a histogram of count of orders per user. I need to be able to filter this measure later on based on specific dates.
Maybe I don't have to realize this in a measure but in a seperate table or column? Not really sure how to proceed here. Any help is appreciated. I have created this measure using SUMMARIZE in a seperate table, but this is of course no longer sensitive to filtering by order date.
Best

If you're only trying to figure out how many instances of orders there were for each User ID you can use the formula below. As you filter you date with a slicer this will adjust accordingly. Make sure to pull User Id somewhere in your visual to show the orders by User Id.
Orders = Countrows( [Orders] )

Related

Change X axis date range start point depending on user selection

So for the purposes of this quandry, I have two tables in Power BI desktop. A 'Finance' and a 'Calendar' table.
The Calendar table has a filter (towards) relationship with 'Finance.' They are joined on Finance[Transaction date] = Calendar[date].
Finance contains transactions from individuals, there might be multiple for each individual.
I want to know how I can display a count of transactions by year for a selected individual (or individuals) from the 'Finance' table on a bar graph axis in a way that the dates start at the point of their first transaction, rather than the first date in the calendar table.
I'm open to changing the model, so any way of achieving this independent of my current setup is welcome. Any help much appreciated.
Im not quite sure this is what you are looking ,
If you want to show numbers on your whatever visualization you can add it from here
it displays numbers accordingly

How to use a date slicer to filter two visualizations of two different columns in the same table in PowerBI

I have searched for this query and attempted to implement some solutions i've found but i've not been able to apply the solutions to my problem so i'm hoping you can help.
We have a table with data, including "created" and "submitted" date columns. I'm wanting to use one slicer to individually show how many results for items created on the selected date, and items submitted on the selected date.
Any help would be great.
Thanks in advance.
You will need a calendar table for this to work correctly as you will have to have a relationship between your data table and the calendar.
Using this example
In the above table, there is Order and Shipping Date, with a quantity column.
The calendar table is connected by the data column to the Order and Shipping Date. As you can only have one active relationship between the table, one is set as inactive. In this case the Shipping Date is Inactive.
So if I select a filter of 07/01/2018 on the Order data it will not show the quantity of items shipped, just the items ordered as it will filter out those rows.
In the above image, the table has been filtered using the active relationship and it only shows Orders for the 7th and Shipped on the 12th as that is what is in the table (Visual on the right)
So you will need two measures, one using the active and one using the inactive.
So you count the Orders as normal, and the Shipped with a relationship modifier:
Total Orders = SUM('TableName'[Quantity])
Total Shipped = CALCULATE(SUM(Billing[Quantity]), USERELATIONSHIP(Billing[Shipping Date], 'Calendar'[Date]))
USERELATIONSHIP forces the Total Shipped to ignore the filter context on active relationship and use the inactive one.
So it should return Shipped 366, Ordered 353 for the 7/01/2018. You'll need to use the calendar table in your visuals to drive the dates, not the dates in your data.

SUM LOOKUPVALUE with condition

I would like some help figuring out some DAX in Power BI.
I’ve included two screenshots of some mock tables I created in Excel to provide context. I have one master table called Financials which has all of the financial transactions associated with a claim number. I have another table called Test which is built from the Financials table.
The Test table contains the distinct values of claim numbers since in the Financials table a claim number can have multiple transactions. In the event that a claim number has multiple transactions, it would be on separate rows, as shown in the screenshot. Below is the formula I used to create my Test table with distinct claim numbers.
Test Table = distinct(Financials[Claim Number])
My Request
In reference to the screenshot for the attached Test table, I would like to create two columns titled Investigation and Settlement. In plain English, I would like the DAX formula to sum the check amount if the payment type in the Financials table is Investigation. The same logic would apply when payment type is Settlement. In the end I will have one column for Investigation and one column for Settlement, as shown in the Test table image.
I’m thinking something like: if lookupvalue from payment type in Financials = 'investigation' then sum check amount. Also, not sure if I would use SUM or SUMX.
The Test table will then have one row for each claim and it will have summed up all of the investigation payments and all of the settlement payments for the related claim from the Financials table.
Thank you for any help. I'm sure it's easy yet I can't figure it out!
Create a new table and write this code:
test_table =
SUMMARIZE(
financial_table,
financial_table[Claim Number],
financial_table[Claim Status],
financial_table[Date Closed],
financial_table[Legal],
"Investigation", CALCULATE(
SUM(financial_table[Check Amount]),
financial_table[Payment Type]="Investigation"
)+0,
"Settlement", CALCULATE(
SUM(financial_table[Check Amount]),
financial_table[Payment Type]="Settlement"
)+0
)

DAX Joint value

I am trying to create a measure in DAX to find the joint value (sum) of a fact table by filtering two dimension tables to have the same column value.
Here's an image of the relationship
Each Department in Users are linked to table Registret. They are giving resources to projects. The table Projects are Taking Resourcs. What I am trying to accomplish is a measure that can find the amount a department uses of it's own resources. So I figure if I can filter Registret[Users] and Registre[Project] where Users[Department] = Projects[Department] I would get the value.
I'd like to use the Projects[Department] as a basis. So that table below would show the amount of internal department registration by each Department in Projects.
Department(Projects) InternalRegistration
A Value
B Value
So far I've been trying with something like
CALCULATE(Registret[Registret]; FILTER(Users; Users[Department] IN ALLSELECTED(Projects[Departments])))
But this will only show the correct value if I in a slicer single out a Department from table Projects. Is it possible the solution is some Joint table between Users and Projects?
Edit:
The top table shows the matrix of joint values in Registret between Users and Projects.
Edit2:
Image of my table data.
Notice that the filter arrows only point downward. This means that selecting Projects[Departments] isn't going to filter Users[Departments] since there is no filter path connecting them. You are also missing the SUM function in your measure.
Try tweaking your measure to the following:
= CALCULATE(SUM(Registret[Registret]);
FILTER(Users; Users[Department] = SELECTEDVALUE(Projects[Departments])))
If you're working in a matrix or a table, the SELECTEDVALUE should pick up the row/column filter context from the visual, whereas ALLSELECTED only picks up filter context from slicers or report/page/visual level filters.
You can also use ...IN VALUES(... instead of ...= SELECTEDVALUE(....
= CALCULATE(SUM(Registret[Registret]),
FILTER(Users, Users[Department] IN VALUES(Projects[Department])))
Both of these should produce the following:

ALLSELECTED not applied on Calculated Column

I have two tables as indicated below. The first is a list of dates, the second a list of contracts with their contract start and end dates. The tables are not related since there are two date realtionships. I need to give a summary of how many contracts started and ended on each day. This works fine using a calcualted column, however, when I try and slice on Type or Contract customer, the results in the Date table's calculated columns do not apply, even though ALLSELECTED is applied. How can I get the slicers to filter the rows returned to the to calculated column so that the number of contracts are calculated accordingly.
Calculated column:
StartedContracts = COUNTROWS(FILTER(ALLSELECTED(Contracts), Contracts[StartDate] = DateData[Date]))
Reproduction PBIX here
To get this displaying correctly, an easy way is to go ahead and set up the relationships between the tables. You'll have an active relationship and an inactive relationship, something like this with an active relationship to [StartDate] and an inactive relationship to [EndDate]:
Having done this, defining the measures is simplicity itself!
StartedContracts = COUNTROWS(Contracts)
EndedContracts = CALCULATE(COUNTROWS(Contracts), USERELATIONSHIP(Contracts[EndDate], DateData[Date])
Since the active relationship is to the Contracts[StartDate] column, you don't need to specify any additional filters for StartedContracts.
When calculating EndedContracts you just need to add USERELATIONSHIP() to the CALCULATE() function to tell it to use the inactive relationship which was previously defined to the Contracts[EndDate] column.
Slicers on other columns work as expected.