Date:
Customer
Sales
User
Last Order
Order Sent
1001
abc
1001
afe
1001
wr3
1002
avc
1/1/2021
Yes
1002
abc
1003
abc
1/1/2021
Yes
I have the table above and I need a "Dax formula" that will label the Sales as yes for all users for each customer if the last order has a date value in it. or order sent is Yes, I'm open to either.
When I can make a filter that would show if that one line has an order but I need help making the entire customer for sales if they have placed an order.
If this is the desired result, you can calculate Sales using a measure like this:
Sales = CALCULATE(
MAX(Customers[Order Sent]),
ALLEXCEPT(Customers,Customers[Customer]))
This video is a good example of how to calculate the max within a group using a measure.
Related
I'm new to Power BI and struggling a bit with concepts. My simplified problem is this:
I have a table with time-track data (possible multiple entries per day for the same user):
datetime
timeTracked (hours)
user
2022-12-01 14:15
1.5
john
2022-12-01 16:30
0.5
john
2022-12-02 12:00
2.5
tom
I also have second table with yearly wages for each user (irregular dates, wage is applicable from that day forward):
date
user
wage
2021-01-01
john
20000
2021-06-15
tom
25000
2022-02-01
john
22000
I want to somehow calculate the cost for a dynamic period or total time, but using other filters (like client).
For example: total cost for current month - the sum of hours for each user multiplied by hourly cost (let's say yearly wage / 1500 for simplicity). The complication is that there might be multiple applicable wages in the selected period.
I'm not sure if I should create a new table, new column(s) to existing table(s), measure(s) or anything else? I don't know how to deal with this problem in Power BI, any hints, links or examples are very appreciated!
As per the below scenario,I need to exclude all the rows in the table Sales with columns Client,sales,salesdate and region which fall outside the selected maximum and minimum date range of the date slider.
Could anyone please suggest a DAX , I will share my DAX query which is not working.I tried to search official guides in PowerBI for selectedValues() to handle this date filter condition but nothing seems to be working.
I created a Calendar table with distinct values of the dates as present in the Sales Dates column of the Sales table. There is no relationship between these two tables. I used the below DAX measures to handle the filtering criteria for excluding the rows:-
Below measures are meant to find maximum and minimum dates in the selection slider
MaxDate=MAX(DateDimention[Dates])
MinDate=MIN(DateDimention[Dates])
Below ExcludedMeasure is meant to set 1 flag to the values other than selected values which are selected for both min and max dates.
I dragged and dropped it in the visual filter of my table Sales and set it to dont show.But it seems to be not working.
Please suggest how can I fix it.
ExcludeMeasure = IF (SELECTEDVALUE(Calendar,Calendar[MinDate],0,1),
IF (SELECTEDVALUE(Calendar,Calendar[MaxDate],0,1)
My Present Visualization and independent Calendar table to be used in the filter slider:-
Present visualization
Independent Calendar Table
Input data source [Excel]
Client Sales SalesDates Region
A 1000 1.1.2000 USA
A 100 1.2.2000 USA
A 200 4.3.2000 USA
B 110 4.3.2000 Europe
B 1000 5.4.2000 Europe
B 200 6.8.2001 Europe
C 1100 7.9.2001 Asia
C 2000 8.12.2001 Asia
D 100 1.2.2002 Australia
D 1300 6.3.2002 Australia
E 100 7.5.2002 Africa
Expected Results :
If I select Minimum slider date as 01.04.2001 and maximum slider date as 1.09.2001 in my[Dates] filter visualization, then it should return the below results after excluding '5.4.2001' and '6.8.2001':-
Client Sales SalesDates Region
A 1000 1.1.2000 USA
A 100 1.2.2000 USA
A 200 4.3.2000 USA
B 110 4.3.2000 Europe
C 1100 7.9.2001 Asia
C 2000 8.12.2001 Asia
D 100 1.2.2002 Australia
D 1300 6.3.2002 Australia
E 100 7.5.2002 Africa
Kind regards
Sameer
A relationship between the date table and the sales table would be ideal, as when you filter the date from the date table, the filter would exclude the records from the sale tables.
If you can't have a date table with the relationship, your exclude measure needs to be something like this:
Exclude =
CALCULATE(COUNT(Sales[Id]),
Sales[SalesDates] >= [MinDate] &&
Sales[SalesDate] <= [MaxDate]) > 0
I have a table with customers' SSN, account number, purchase date, and max purchase date (the most recent purchase date for SSN, across all the accounts). Customers can have multiple accounts. I know how to create a measure the calculate the distinct count of all the accounts that haven't been active since a certain date (6 months, 18 month, 24 months)..
I would like to create a measure or a calculated column to give me the following information.
when users select the date from the slicer (say 6 months) the chart shows the count of the accounts that have not made a purchase in 6 months, the users also want to have a drop down slicer("Yes", "No") to indicate if the SSN had activities under other accounts. i.e. if the max purchase date is greater than the value from the date slicer.
the table structure looks like this:
SSN AccountNumber LastPurchaseDate MaxPurchaseDate
123-45-5678 9876 8/2/2018 9/4/2019
123-45-5678 6398 9/4/2019 9/4/2019
135-65-4321 2233 6/6/2019 6/6/2019
Best way here would be if you add a custom column with the time difference (in the query designer):
= [MaxPurchaseDate] - [LastPurchaseDate]
Now you have something like this:
SSN AccountNumber LastPurchaseDate MaxPurchaseDate DateDiffDays
123-45-5678 9876 9/2/2018 9/4/2019 2
123-45-5678 6398 9/4/2019 9/4/2019 0
135-65-4321 2233 6/12/2019 6/6/2019 6
You can add another column which acts as filter for your 6 months, 18 month, 24 months (convert the DateDiffDays into months).
The following measure counts the accounts:
=Distinctcount('YourTable'[AccountNumber])
If you filter now by your 6 months, 18 month, 24 months column the measure gets after every filtering calculated again and you get your result.
I have two tables:
Table A, which indicates where my truck is for each day,
Date Truck Region
5/20/2018 1014 NY
5/21/2018 1014 NJ
and Table B (which contains when my truck inspection was done for each day). Sometimes there may be more than one inspection record, but I only need the last one by truck by day. As you can see, I added a rank column. Truck 1014 has two records for 5/20/2018, but the last one gets ranked as 1 (I will filter the table by 1).
Date Time Truck Rank
5/20/2018 5/20/18 9:00 AM 1014 2
5/20/2018 5/20/18 2:00 PM 1014 1
5/21/2018 5/21/18 2:50 PM 1014 1
I want to merge those two tables together. The reason I ask how to do it in the query editor is that, in the relationship view, you cannot create a relationship on two columns. For example, in my example, I want to join data by date and by truck number, which I cannot. What is the right direction for this situation?
In the query editor, you can use the Merge Queries button under the Home tab.
(You'll need to hold down the Ctrl key to select multiple columns.)
Once you've merged, just expand the columns from Table B that you want to bring over (e.g. Time and Rank). If you did not filter Rank = 1 before merging, you can include it when expanding and filter afterward.
Note that you can also use the LOOKUPVALUE DAX function outside of the query editor. As a new column on Table A:
Time = LOOKUPVALUE('Table B'[Time],
'Table B'[Date], [Date],
'Table B'[Truck], [Truck],
'Table B'[Rank], 1)
Good day. I am looking for a way to group the table below per day and count ID's using a measure, in order to be able to get max count, min count, percentile etc..
Date ID
2018-01-01 ABC
2018-01-01 DEF
2018-01-01 GHI
2018-01-02 JKL
2018-01-02 MNO
2018-01-03 PQR
2018-01-03 STU
2018-01-03 VWX
I can create a table like that using:
group_by_count = SUMMARIZE(Table1;Table1[Date];"count";COUNTROWS(Table1))
Date count
2018-01-01 00:00:00 3
2018-01-02 00:00:00 2
2018-01-03 00:00:00 3
However, I don't want an extra table in my report as my real data contains some years of data and other interesting columns I will filter on. Any ideas how to go about to do this, using only measures?
Further clarification:
My end goal is to get a measure that, for example, returns the max count. With my example data that would be 3. I will use this measure in cards and build dynamic texts for cards. Then I could build a text that says for example: "The maximum number of events in one day was 3".
You don't need to actually create a new table. You can use the SUMMARIZE function within a measure. For example,
MaxCount = MAXX(SUMMARIZE(Table1; Table1[Date]; "Count"; COUNT(Table1[ID])); [Count])