I have a table with a date column and a money column:
Thedate CashCollected
2039-12-28 100
2039-12-27 200
2039-12-26 300
2039-12-25 400
2039-12-24 500
2039-12-23 600
2039-12-22 700
2039-12-21 800
and then I have the date table with the date and the previous working day calculated following some specific conditions:
TheDate PrevItWorkDay
2039-12-28 2039-12-27
2039-12-27 2039-12-23
2039-12-26 2039-12-23
2039-12-25 2039-12-23
2039-12-24 2039-12-23
2039-12-23 2039-12-22
2039-12-22 2039-12-21
2039-12-21 2039-12-20
I would like to calculate in DAX a measure which gives me the sum of cash collected for the previous working day in the date table:
TheDate PrevItWorkDay
2039-12-28 200
2039-12-27 600
2039-12-26 600
2039-12-25 600
2039-12-24 600
2039-12-23 700
2039-12-22 800
2039-12-21
How can I do this?
PrevWorkingDaySum =
CALCULATE(
SUM(TransactionTable[CashCollected]) ,
TransactionTable[Thedate]= SELECTEDVALUE(DateTable[PrevItWorkDay])
)
Related
I'm trying to achieve the column "Sales = Chair" in power bi. The goal is to filter value for a specific category and populate the value in the rows of the same column.
Category Subcategory Sales Sales = Chair
Furniture Chair 100 100
Furniture Sofa 150 100
Appliances Washer 250 100
Appliances Microwave 200 100
Can you try a measure like-
new_column =
CALCULATE(
SUM(your_table_name[Sales]),
FILTER(
ALL(your_table_name),
your_table_name[Category] = "Furnuture"
&& your_table_name[SubCategory] = "chair"
)
)
I have a table
Year_month amount
08-2021 100
09-2021 200
10-2021 300
I want to add a column Month to be
Year_month Month amount
08-2021 01-08-2021 100
09-2021 01-09-2021 200
10-2021 01-10-2021 300
It depends of the type of data you have. check below code:
with sodata as (
select '08-2021' as Year_month_string, PARSE_DATE("%m-%Y", "08-2021") as Year_month_date, 100 amount,
union all
select '09-2021',PARSE_DATE("%m-%Y", "09-2021"), 200
union all
select '10-2021',PARSE_DATE("%m-%Y", "10-2021"), 300
)
SELECT Year_month_string,FORMAT('01-%s',Year_month_string) as using_format,FORMAT_DATE("%d-%m-%Y", Year_month_date) as using_format_date,amount from sodata
output
Row
Year_month
using_format
using_format_date
amount
1
08-2021
01-08-2021
01-08-2021
100
2
09-2021
01-09-2021
01-09-2021
200
3
10-2021
01-10-2021
01-10-2021
300
To see more details about the functions used please go to this links:
Format (string)
Format Date
You can use Parse date function
SELECT PARSE_DATE("%m-%Y", "08-2021")
I am trying to get a sum of one column based on the date in another.
Count
Date
100
05/01/2021
200
05/01/2021
300
05/01/2021
100
06/01/2021
200
06/01/2021
400
06/01/2021
100
07/01/2021
300
07/01/2021
500
07/01/2021
In SQL what I want is:
SELECT SUM([COUNT]) WHERE [Date] = MIN([Date]) FROM [rpt_data]
I can't figure out how to do this in DAX. I tried:
CALCULATE( SUM([Count]), MIN([Date]) )
But it says that I can't use MIN as a filter.
I know this works: CALCULATE( SUM([Count]), rpt_data[Date] = "07/01/2021" ) But I need to know the first and last dates dynamically.
I need another with MAX[Date]) but I figure if I get one figured out I'll figure out the other.
Currently, the engine doesn't know what do you want. We need to show which column we want to compare with a date. Example:
measure =
var __minDate = calculate( min(OrderTable[Date]))
return
CALCULATE( SUM(SalesTable[Count]), FILTER(ALL(SalesTable[Date]), SalesTable[Date] = __minDate)
I have a table with dates and prices:
28/01/2016 100
04/02/2016 200
16/04/2016 100
23/04/2016 150
07/05/2016 150
14/05/2016 200
.
.
01/12/2017 80
08/12/2017 200
I would like to get a sum based on the month and then year, as follows:
01/2016 100
02/2016 200
04/2016 250
05/2016 350
.
.
12/2017 280
The date is currently in DDMMYY10. format.
Convert any individual date value within a month to a the same value and group by that. For example by using INTNX() function.
select intnx('month',date,'b') as month format=yymm7.
, sum(price) as total_price
from have
group by month
Or convert it to a string using PUT() function.
select put(date,yymm7.) as month
, sum(price) as total_price
from have
group by month
I have a value that is valid for a period of time, for example, 1200 minutes overtime period of 2020-01-01 to 2020-12-31.
format:
Start date, End date -> total time in minutes
2020-01-01, 2020-12-31 -> 1200
What's the best way to be able to split it by day/week/month (i have a calendar table ready)?
The end goal is to present it on the graph cumulatively as well as additional data from the other table that will show progress against this target.
Additional data is logged per day in the format:
DATE -> VALUE in minutes (not cumulative)
so (reflected in the 2nd chart below):
2020-02-05 -> 300 minutes
2020-05-22 -> 200 minutes
2020-07-12 -> 100 minutes
2020-09-02 -> 300 minutes
2020-10-05 -> 100 minutes
2020-11-09 -> 100 minutes
2020-12-12 -> 100 minutes
You could simply create an index column in your date table and then scale that one according to your desired trend:
Expected = RANKX ( 'Calendar', 'Calendar'[Date], , ASC ) * 1200 / 366