when i enter:
Schedule Finish vs Today measure =
IF ( MAX ( oData_Activity_Dimension[Actual_Finish] ) <= TODAY(), 1,
IF ( MAX ( oData_Activity_Dimension[Schedule_Finish] ) <= TODAY(), 0,
0 ) )
the column populates with all 1's.
when i turn it around and enter
Schedule Finish vs Today measure =
IF ( MAX( oData_Activity_Dimension[Schedule_Finish] ) <= TODAY(), 0,
IF ( MAX( oData_Activity_Dimension[Actual_Finish] ) <= TODAY(), 1,
0 ) )
the column populates with all 0's.
what am i doing wrong? i am trying to get a custom column so that if there is a schedule finish less than todays date, it will be 0(so i can condit format this to red), and if there is an actual finish present at all it will be 1(condit format this to stay as black).
the red indicates its late. actual finish does apply.
any tips/help on how to write this?
Much appreciated,
Kevin
Related
I have 2 columns that includes 2 different dates.
What i'm trying to do is to create a calculated column that determines whether column "governance" is <= TODAY and the "contract issue" column is between the start and end of the next month( only March dates). with either "yes" or "no" in the if statement.
i've tried the following measure:
IF ( 'Table'[Governance] <= TODAY() && 'Table'[Contract Issue] <= EOMONTH ( Today(), 1 ), "yes", "No" )
but that returns all contract issues before end of the next month, what do i use to show the contract issue date between start of the next month and end of the next month?
Sample table below
Governance
Contract Issue
14/01/2022
04/03/2022
04/02/2022
11/03/2022
Much thanks in advance
It seems you just need to compare the date to the start of the month.
mymeasure = IF (
'Table'[Governance] <= TODAY ()
&& 'Table'[Contract Issue] <= EOMONTH ( TODAY (), 1 )
&& 'Table'[Contract Issue]
>= DATE ( YEAR ( 'Table'[today] )
+ IF ( MONTH ( 'Table'[today] ) = 12, 1, 0 ), MONTH ( 'Table'[today] )
+ IF ( MONTH ( 'Table'[today] ) = 12, -11, 1 ), 1 ),
"yes",
"No"
)
You'll need a "today" column, too. Do that in Power Query using M:
Date.From(DateTime.LocalNow())
I am trying to compute the percentage of Free to Paid Sales conversions for a particular period.
Sales become paid after the threshold of 5 days. So Conversion % should exclude the last 5 days. Expected output is below.
Below are the measure I have created.
FreeSales : SUM( DATA[Free_Trials])
Conversions : SUM(DATA[Conversions])
Conv % : Calculate ( DIVIDE( FreeSales/Conversions,0), DATESBETWEEN(DATA[DATE], STARTDATE, ENDDATE-5))
(P.S: STARTDATE & ENDDATE are the min & max values from the date slicer)
Conv % is not working properly . It giving same value for all the rows in the table. Please help to fix this issue.
Thanks in advance!
You can create a calculated column with the below DAX formula.
Column2 =
VAR C = MAX ( Sheet1[Date] )
VAR RESULT =
IF (
( Sheet1[Date] ) = C,
0,
IF (
Sheet1[Date] = C - 1,
0,
IF (
Sheet1[Date] = C - 2,
0,
IF (
Sheet1[Date] = C - 3,
0,
IF (
Sheet1[Date] = C - 4,
0,
CALCULATE ( DIVIDE ( SUM ( Sheet1[Paid Sales] ), SUM ( Sheet1[Free Sales] ) ) )
)
)
)
)
)
RETURN
RESULT
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I want to display percentage increase or decrease in total for each month as I select each month i.e when I click on FEB, it should tell me whether there was a percentage increase/decrease in expenses compared to JAN.
I have tried different codes but keep getting an error message.
Here is a DAX CODE I tried:
change perc =
VAR ValueLastMONTH =
CALCULATE (
SUM ( population[TOTAL] ),
FILTER (
population,
population[MONTH]
= ( EARLIER ( population[MONTH] ) - 1 )
&& population[CATEGORY] = EARLIER ( population[CATEGORY] )
)
)
RETURN
IF (
ISBLANK ( ValueLastMONTH ),
0,
( population[TOTAL] - ValueLastMONTH )
/ ValueLastMONTH
I want a new column created to display the percentage increase or decrease from a month to its previous month.
Here is a screenshot of the excel document:
The Column 'Month' is not of type date. How would PowerBi know the text APR represents April? You need to make this column a date.
Now you need to change the script to work with DateDiff:
change perc =
VAR ValueLastMONTH =
CALCULATE (
SUM ( population[TOTAL] ),
FILTER (
population,
DATEDIFF(population[MONTH], EARLIER ( population[MONTH] ),MONTH) = 1
&& population[CATEGORY] = EARLIER ( population[CATEGORY] )
)
)
RETURN
IF (
ISBLANK ( ValueLastMONTH );
0;
( population[TOTAL] - ValueLastMONTH )
/ ValueLastMONTH)
I have the that has some data related to employee start date and end date for specific task
How to calculate "Total Working days" using the above data in PowerBi
The expected ouput would be number of days this employee worked (according to date )
so for example
12/2/2018 12/3/2018 = 1 working Day
but if same record repeated this would remain one working day
Output from Formula
Screenshot of PBX File
You can calculate the working day in various ways, I'll give you two options (both are calculated columns):
WorkingDays1 = Tasks[EndTime] - Tasks[StartTime]
(Assuming it's a date column type), you can add .DATE to be sure behind the column)
OR
WorkingDays2 = DATEDIFF(Tasks[StartTime];Tasks[EndTime];DAY)
If you want to correct the amount, for the same day, you can use an IF statement:
WorkingDays3 =
IF (
Tasks[StartTime] = Tasks[EndTime];
1;
DATEDIFF ( Tasks[StartTime]; Tasks[EndTime]; DAY )
)
If you wish to SUM the days, in a measure, you can SUM one of the generated columns above, OR you can create a measure which doesn't need such column: It iterates over the rows, and caculates the correct amount:
SUM WorkingDay =
SUMX (
Tasks;
IF (
Tasks[StartTime] = Tasks[EndTime];
1;
DATEDIFF ( Tasks[StartTime]; Tasks[EndTime]; DAY )
)
)
Result:
Note: These calculations do not take the weekends, or holidays into account.
Edit:
If you only want a unique list of dates, with the working days, you can use something like this. It itarates over the start dates:
SUM WorkingDay2 =
SUMX (
VALUES ( Tasks[StartTime] );
IF (
DATEDIFF ( Tasks[StartTime]; CALCULATE ( MAX ( Tasks[EndTime] ) ); DAY ) = 0;
1;
DATEDIFF ( Tasks[StartTime]; CALCULATE ( MAX ( Tasks[EndTime] ) ); DAY )
)
)
Edit 2:
If you want to create an unique list per day, you'll have to get rid of the time part in the datetime column. There are several ways to do this, but one option is to create a new column:
StartDate = Tasks[StartTime].[Date]
Then, you can adjust the measure by iteration over the dates, instead of the datetimes:
SUM WorkingDay3 =
SUMX (
VALUES ( Tasks[StartDate] );
IF (
DATEDIFF ( Tasks[StartDate]; CALCULATE ( MAX ( Tasks[EndTime] ) ); DAY ) = 0;
1;
DATEDIFF ( Tasks[StartDate]; CALCULATE ( MAX ( Tasks[EndTime] ) ); DAY )
)
)
I'm trying to get cumulative number of unique IDs in given timeframe.
My DAX look like this:
Cumulative = CALCULATE(SUM(Data[ID]));DATESBETWEEN(Data[ack_date];DATE(YEAR(NOW());4;1);DATE(YEAR(NOW());11;30)))
There is similar measure for Year-1: [YEAR(NOW())-1]
What I want to achieve is area chart showing growing number od IDs in time comparing same periods this and previous year. When I give those measures as Values for chart and "ack_date" as its Axis what I get is values comparison month by month but not cumulative, just value for certain month.
Try this code. Adjust for year -1.
=
CALCULATE (
DISTINCTCOUNT ( Data[ID] ),
FILTER (
ALL ( Data ),
AND (
Data[Ack_date] <= MAX ( Data[Ack_date] ),
AND (
Data[Ack_date] <= DATE ( YEAR ( NOW () ), 11, 30 ),
Data[Ack_date] >= DATE ( YEAR ( NOW () ), 4, 1 )
)
)
)
)