DAx Formula Counting tasks - powerbi

I have a question regarding Dax formula in PowerBI. All help is appreciate. I need to present some results on monday...
Table example
Task column can have different fields (Partner Acknowledgment, IPM HandOff, Pre Engagement Process...)
Task status can only have 2 values (closed or Received)
I have my formulas that work but now I need to add an extra filter and is getting error:
THe Filter part is giving me problems (WHen task= IPM HandOff is Task_status = Closed)
Total Tasks = All the tasks (rows) that contains the word "Partner Acknowledgment" in the task column.....And I try to add a filter when "IPM HandOff" in the task column has task_status closed:
Tasks =
CALCULATE (
COUNTA ( CELERGO_12062021V1[TASK] ),
CONTAINSSTRING ( CELERGO_12062021V1[TASK], "Partner Acknowledgement" ),
FILTER (
CELERGO_12062021V1,
CELERGO_12062021V1[TASK] = "IPM HandOff"
&& CELERGO_12062021V1[TASK_STATUS] = "Closed"
)
)
Total Tasks with GLD = Same as the previous one but with a schedule Date in the column Schedule.....And I try to add a filter when "IPM HandOff" in the task column is Task_status = closed.
Partner Acknowledgment with GLD = CALCULATE ( COUNTA ( CELERGO_12062021V1[SCHEDULED] ), CONTAINSSTRING ( CELERGO_12062021V1[TASK], "Partner Acknowledgement" )) ,
FILTER (
CELERGO_12062021V1,
CELERGO_12062021V1[TASK] = "IPM HandOff"
&& CELERGO_12062021V1[TASK_STATUS] = "Closed"
)
)
Total Tasks with GLD = Same as the previous ones but with a schedule Date in the column Schedule and Task Status Closed for the task "Partner Acknowledgmeent".....And I try to add a filter when "IPM HandOff" in the task column is Task_status = closed.
Partner Acknowledgment with GLD & Closed = CALCULATE ( COUNTA ( CELERGO_12062021V1[SCHEDULED] ), CONTAINSSTRING ( CELERGO_12062021V1[TASK], "Partner Acknowledgement" ) && CELERGO_12062021V1[TASK_STATUS] = "Closed" ) ,
FILTER (
CELERGO_12062021V1,
CELERGO_12062021V1[TASK] = "IPM HandOff"
&& CELERGO_12062021V1[TASK_STATUS] = "Closed"
)
)
ANy idea got to add this extra field in the formulas? "WHen task= IPM HandOff is Task_status = Closed) Thanks :)
last part... Is it possible to get the formulas + extra filter counting only the tasks owned by some people (names??) I want to know the formulas below that belong to Taskactualperformer = Roger, Abbie and Veronika"?
Same table. I need to combined the 2 formulas below...
To get all the clients with
Task = "pre engagement Team" and Tast_Status (Closed and Received) - Formula 1
&&
Task = "IPM HandOff" and Task_Status is Received - Formula 2
Tried different options but no exit.
Formula1 = VAR result =
CALCULATE (
DISTINCTCOUNT( CELERGO_12062021V1[CID] ),
FILTER (
CELERGO_12062021V1,
CELERGO_12062021V1[TASK]
= "Pre Engagement Process"
&& CELERGO_12062021V1[TASK_STATUS] IN { "Closed", “Received” }
)
)
RETURN
IF ( ISBLANK ( result ), 0, result )
FOrmula 2 =
VAR result =
CALCULATE (
COUNT ( CELERGO_12062021V1[CLIENT_NAME] ),
FILTER (
CELERGO_12062021V1,
CELERGO_12062021V1[TASK] = "IPM HandOff"
&& CELERGO_12062021V1[TASK_STATUS] = "Received"
)
)
RETURN
IF ( ISBLANK ( result ), 0, result )
last part... Is it possible to get the formulas + extra filter counting only the tasks owned by some people (names??) I want to know the formulas below that belong to Taskactualperformer = Roger, Abbie and Veronika"?
Thanks

I would recommend splitting those measures into simple ones.
As I understand, you want to count the number of rows that contain 'Partner Acknowledgment' in the task column and add the number of rows that have the value "closed" in the status column and the value 'IPM HandOff' in the task column. Then you can try this:
Count rows:
Total Tasks =
COUNTROWS ( 'TableA' )
Count rows where tasks contain 'Partner Acknowledgment':
Partner_Acknowledgment_Total =
CALCULATE (
[Total Tasks],
CONTAINSSTRING ( 'TableA'[task], "Partner Acknowledgment" )
)
Count rows where tasks are equal to 'IPM HandOff' and status = 'closed'
IPM_HandOff_closed_Total =
CALCULATE (
[Total Tasks],
'TableA'[task] = "IPM HandOff",
'TableA'[status] = "closed"
)
Final measure:
Partner_Acknowledgment+IPM_HandOff_closed =
[Partner_Acknowledgment_Total] + [IPM_HandOff_closed_Total]
Measures are for the table:

Related

Power BI - Count of keys on start month

I have a visual in which I am showing the Count of Keys with status <> "Closed" for each month.
I have a Date table connected to the model(a relationship exists between this table and the other tables of the model) and I have created a new Date_dimension table in order to be able to see in the visual all the previous months of the filtered month:
NumberOfKeys =
IF (
SELECTEDVALUE ( 'Date'[Year] ) = SELECTEDVALUE ( 'Date_dimension'[YearNo] )
&& SELECTEDVALUE ( 'Date'[No. Month] ) <= SELECTEDVALUE ( 'Date_dimension'[MonthNo] )
,
DISTINCTCOUNT(History[Key]),
BLANK()
)
And I have this calculated column that tells me if the key has the status "Closed" in the current month, and I am filtering the visual to show only the data for which this column is 0:
#TransitionsToClosed_InThatMonth =
VAR _transitionCount =
COUNTX (
FILTER ( History, EARLIER ( History[Key] ) = History[Key]
&& EARLIER ( History[Status start Month] ) = History[Status start Month]
&& History[History Status] = "Closed"),
History[Key]
)
Return
IF(_transitionCount,_transitionCount, 0)
What I actually need is to show, for each month, the number of keys that are not closed at the beginning of the month, but I'm not sure how to calculate this.

SUMMARIZE or SUM values based on Date fields in another table

I am trying to do a burndown graph on PowerBI.
My data is a list of tasks. Each task has a numerical value (EFFORT) assigned to it and there is a total amount of effort for any given month (sum of all EFFORT). As tasks as set to DONE, the ongoing effort should be deducted from a running total and that value used to plot a graph. I have 3 columns
I would like to have measure to calculate EFFORT REMAINING for each date, i.e.
EFFORT REMAINING = TOTAL EFFORT - (EFFORT WHEN TASKS ARE DONE FOR EACH DAY)
For example,
I did get the consecutive dates displaying:
Burndown = CALENDAR(DATE(2022,7,1),DATE(2022,7,31))
and also the total effort (starting value)
TOTAL EFFORT = SUM(Issues[EFFORT])
Now for each date in table, I need to minus the accumulating total of EFFORT when the status is set to DONE
EFFORT REMAINING = Burndown[TOTAL EFFORT]-SUM(Issues[EFFORT]="DONE" ....
Im stuck after this last point. Can anyone help, please?
you are so close to the answer ). Convert SUM(Issues[EFFORT]="DONE" to:
CALCULATE(
SUM(Issues[EFFORT])
, SUM(Issues[Status]="DONE"
)
Have a nice day.
Please try this measure:
Please ensure that (1-Many) relationship is created between Burndown [Date] and Issues[ISSUE_CREATED] columns.
EFFORT REMAINING =
VAR TblSummary =
ADDCOLUMNS (
SUMMARIZE ( Issues, Burndown[Date] ),
"Total Effort", CALCULATE ( SUM ( Issues[EFFORT] ) ),
"Tasks Completed", CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" ),
"Effort Remaining",
CALCULATE ( SUM ( Issues[EFFORT] ) )
- CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" )
)
VAR Result =
SUMX ( TblSummary, [Effort Remaining] )
RETURN
Result
After that, you can create a clustered column chart, and put [Date field] on calendar table on X_axis and put 'EFFORT REMAINING' measure on Y_axis(Value axis) to see the result.
I hope It solves your problem.
Bonus Info:
If you want to see your Summary table, create a "New Table" and paste this code:
Summary_Table =
VAR TblSummary =
ADDCOLUMNS (
SUMMARIZE ( Issues, Burndown[Date] ),
"Total Effort", CALCULATE ( SUM ( Issues[EFFORT] ) ),
"Tasks Completed", CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" ),
"Effort Remaining",
CALCULATE ( SUM ( Issues[EFFORT] ) )
- CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" )
)
VAR Result =
SUMX ( TblSummary, [Effort Remaining] )
RETURN
TblSummary
The result It produces:
Note: I have limited access to your data sets as you shared above. The result will be exact with your full dataset.

Calculation groups for currency conversion (multiple currencies to multiple currencies)

I have tried to make a calculation group that does my currency conversion for me for all my measures that has a "LC" in its naming. It goes well in most cases BUT when I have a measure with "per sqm" it works when I divide the measure example per country but the total is wrong..
Look at the example - everything is good except for the total for "Average Total Costs per sqm - LC", that should be 562.714 and not 477.788.
enter image description here
VAR MeasureName =
SELECTEDMEASURENAME ()
VAR SkipConversion =
NOT ISCROSSFILTERED ( 'Exchange Rates' )
|| ( SEARCH ( "LC", MeasureName, 1, -1 ) < 0 )
RETURN
IF ( SkipConversion, SELECTEDMEASURE (), VAR AggregatedTotalCost =
ADDCOLUMNS (
SUMMARIZE (
'Fact Tenant Improvement',
'Exchange Rates'[Currency_From],
'Country'[KEY_Countrycode]
),
"#SalesAmountInCurrency", SELECTEDMEASURE (),
"#Rate", CALCULATE (
SELECTEDVALUE ( 'Fact Exchange Rates'[Rate])
)
)
VAR Result =
sumX (
AggregatedTotalCost,
[#SalesAmountInCurrency] * [#Rate]
)
RETURN
Result)
Any ideas on how to handle this?

Giftcard customer transitioning into "real" customer calculation in DAX

I am trying to calculate whether a customer that uses a gift card as his first order, will transition into become a "normal" customer, which means that he/she orders without a gift card next time.
I can see from the PaymentMethod how the customer payed (PaymentMethod = "Gift card")
I have made a column that says "Gift card" if the order is purchased with this, otherwise it is blank.
So basically I want to make a column that states: If the customer has their first purchase with a gift card, and makes a new order later, that is not purchased with a gift card.
So for example a 1 if TRUE, a 0 if FALSE.
I have the following columns in my orders table:
OrderID
CustomerID
BookingDate
PaymentMethod (Cash, Credit Card, Gift card etc.)
Gift card (Blank or Gift card)
I have tried different DAX codes, but the thing is - I don't know how I would write that the first order has to be a gift card order, and the next order from the customer has to be a non-gift card order, so I doubt the DAX code that I have tried, would be relevant.
Here is a picture of what I hope to achieve:
I hope someone can lead me in the right direction, thank you in advance.
I'd suggest something along these lines:
TransitioningCustomer =
VAR FirstOrderDate =
CALCULATE ( MIN ( Data[BookingDate] ), ALLEXCEPT ( Data, Data[CustomerID] ) )
VAR FirstOrderGiftCard =
"GC"
IN CALCULATE (
VALUES ( Data[PaymentMethod] ),
ALLEXCEPT ( Data, Data[CustomerID] ),
Data[BookingDate] = FirstOrderDate
)
VAR PaymentMethods =
CALCULATE (
DISTINCTCOUNT ( Data[PaymentMethod] ),
ALLEXCEPT ( Data, Data[CustomerID] )
)
RETURN
IF ( FirstOrderGiftCard && PaymentMethods > 1, 1, BLANK () )
This calculates the first order date and then check whether a gift card was used on that date. It also counts the total number of (distinct) payment methods used.
The conclusion that if a gift card was used on the first date and there was some other type of payment method used as well as some point in the customer's purchase history, then that is a transitioning customer.
With the help of Alexis i ended up with this, that returns a 1 if a customer uses a giftcard for their first order, and something else than giftcard for their second order.
FirstOrderGiftNextOrderNotGift =
VAR FirstOrderID =
CALCULATE (
MIN ( orders[Column1.Order_ID] ),
ALLEXCEPT ( orders, orders[Column1.Customer_ID] )
)
VAR FirstOrderGiftCard =
CALCULATE (
VALUES ( orders[Column1.PaymentMethod] ),
ALLEXCEPT ( orders, orders[Column1.Customer_ID] ),
orders[Column1.Order_ID] = FirstOrderID,
orders[Column1.PaymentMethod] = "Giftcard"
)
VAR PaymentMethods =
CALCULATE (
DISTINCTCOUNT ( orders[Column1.PaymentMethod] ),
ALLEXCEPT ( orders, orders[Column1.Customer_ID] )
)
RETURN
IF (
FirstOrderGiftCard = "Giftcard"
&& orders[ReturningCustomer] = "Yes"
&& PaymentMethods > 1,
1,
0
)
After calculating this column I just created a measure for counting the distinct 1's of the customer numbers.
CountOfCustomersWhoTransitioned =
CALCULATE (
DISTINCTCOUNT ( orders[Column1.Customer_ID] ),
orders[FirstOrderGiftNextOrderNotGift] = 1
)

I will like a script in power bi that will calculate percentage increase or decrease from one month to the previous month

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)