if statement is not giving desired result in dax - powerbi

I have sales rep column, and their total sales. i am showing the results in the below matrix
so the actual value that i am trying to show from the calculated column as below.
FinalActual = if('Sales Target'[SalesRep] = "ABC",'Sales Target'[totalABC],'Sales Target'[totalseats]-'Sales Target'[totalseatspq] )
so I am trying to show the actual value based on the sales rep name. if the sales rep name is "ABC", then it should show the value of the measure which I created separately. for others it should be Sales Target'[totalseats]-'Sales Target'[totalseatspq]. But the issue here is, for ABC it's not taking the value from the "true condition(Sales Target'[totalABC])" of if statement. its still picking the value of the false condition(Sales Target'[totalseats]-'Sales Target'[totalseatspq]). Please help if I am missing anything here.
Your help is highly appreciated

Related

Get a Department Percent Contribution of Total Sales

Table = opportunity
Dimension Field = Territory
Measure Field = AnnualSales
I want a measure that will take a territories SUM(AnnualSales) and see what percentage it makes of All territories SUM(AnnualSales) would be. I have not been able to accomplish this based off the articles I've read so far. Any help is greatly appreciated
My results would look something like this.
If you want to see results in a table of visualization:
create this measure: CALCULATE(SUM(AnnualSales))
then, drag Territory field in a table, add the new measure created in the table and then go to visualization editor right click on measure and click on show results as a percent of column total.
Waiting your answer ... :)
Regards
I was able to accomplish what I set out with the following.
cm_TotalEstAnnualSales = Calculate(Sum(opportunity[Est. Revenue (Annualized)]),All(opportunity))
cm_PctofTotalEstAnnualSales = Divide(SUM(opportunity[Est. Revenue (Annualized)]),[cm_TotalEstAnnualSales],0)
Thanks for the tips here!

SUMX in Stacked Column chart

I'm hoping for some help with my measures. My data is quite sensitive so it's not easy to share. I've attempted to mock up as sales so hope it makes sense.
https://1drv.ms/u/s!Ap6q8W-mvm27g-dWehgkV6-p33VVsA?e=bGj3nV
I have written a measure to count the number of resales by TransactionID. I then use a sumx to total the resales by Transaction ID.
I've added this measure to a matrix against Month for Banding and this shows the correct row and column totals.
In the FACT Salestable, I have a field 'Tier'. When I attempt to add 'Tier' to a stacked column chart using the same measures, the data is incorrect. I think it is because the sumx is losing the filter created in the first measure but I don't really understand how to rectify this and have been trying for days!
Is anyone able to identify where my measures are incorrect - Id like to try to understand what exactly I'm asking the measure to do so I know where I'm going wrong for future work! Any help would be very much appreciated - thank you!
MEASURE 1:
CountResales =
Var _Cust = Max (FACTSales[CustomerID])
Var _Date = CALCULATE(min(FACTSales[DateOrigSale]),ALLSELECTED(FACTSales),FACTSales[CustomerID]=_Cust)
Var _ID = CALCULATE(min(FACTSales[CohortID]),ALLSELECTED(FACTSales),FACTSales[CustomerID]=_Cust,FACTSales[DateOrigSale]=_Date)
Var _CountResales =
CALCULATE(DISTINCTCOUNT('DIMReSales transactions'[TransactionID]),
VALUES('DIMReSales transactions'[TransactionID]),'DIMReSales transactions'[CohortID]=_ID,
'DIMReSales transactions'[New Sale]=1)
Return
_CountResales
MEASURE 2:
SumResales = Sumx(values('FACTSales'),[CountResales])

Ignore Selections "DAX Function ALL" not working

I got a situation here, i have a measure for "Total Sales" with following expression
Total Sales = CALCULATE(SUM(Sale[total]), ALL(Customer))
I have a visualization in which i am displaying product-sales by customer.
If i make a customer-name selection in that visualization then this measure (mentioned above) changes its value. Why?
Both scenarios are shown in following screenshot (measure-value without customer-name selection & measure value with customer-name selection:
Data-Model Screenshot:
I changed the formula to ignore both tables
Total Sales = CALCULATE(SUM(Sale[total]), ALL(Customer), ALL(Product))

Not able to get top 1 in power BI?

Customer table
contains the column "Status","created_date","updated date"
ascs table
contains the column "service_station_name"
First I add new measure for "status count" by using following eqn:
Status Count = COUNT('cps customers'[status])
then a new column for "day duration" by using following eqn:
Day Duration2 = SWITCH('cps
customers'[status],"Closed",DATEDIFF('cps customers'[created_at],
[updated_at],DAY),"Unattended",DATEDIFF('cps
customers'[created_at],NOW(),DAY),"Assigned",DATEDIFF('cps
customers'[created_at],NOW(),DAY),"NotApplicable",DATEDIFF('cps
customers'[created_at],NOW(),DAY),"Open",DATEDIFF('cps
customers'[created_at],NOW(),DAY))
I need top service station name..
Conditions:
i. Consider only **closed status**
ii. Top count of **closed status count**
iii. Lowest **time duration**
Steps:
Select columns service_station_name,status,status count and day duration2
Filter the closed status from column "status".
Add TOPN filteration for "status count"
Now, I got three service_station_name where each have 5 closed status count.
And for getting the lowest "day duration2" I used ascending order
"
And for displaying the top 1 service_station_name, I chosen the CARD from
visualization and get First service_station_name.Bt I haven't got the
proper answer
Then I took last service_station_name . Here also i haven't got the
answer.
Based on the screenshot, I need "Om Sakthi Engineering" as answer.
How I get the answer? Can anybody help me!
You could actually add in another column "NewColumn", then the value would be the "Status Count" divided by "day Duration". The highest value will be the top one.
NewColumn = divide(Table1[Status Count],Table1[Day Duration])
Then you can use card visualization to pick the top one value.
Under filters, you should filter status as closed, filter the top 1 for this NewColumn.

Sharepoint calculated column based on other columns #NULL! error

I am trying to add two currency columns in a calculated column but am getting a #NULL! error.
This seems pretty straightforward but its my first time doing this in SharePoint.
SharePoint 2010 with Excel Services available.
Have create List with required columns:
Approved Value column Type = Currency
Pending Value column Type = Currency
Total Value column
Calculated (calculation based on other columns)
Type = Currency
Formula: =[Approved Value]+[Pending Value]
The values in other columns are indeed currency, but the Total shows #NULL! for all items.
I can't see anything done incorrectly.
What should I be looking for to resolve this problem?
Try using the ISBLANK function to previously check if any of the value is null.
Reference: ISBLANK function
I ended up using NZ(Value, 0)
=NZ([Approved Value],0)+NZ([Pending Value],0)
Though not sure how NULLs ended up in field or why SharePoint couldn't deal with them without this special treatment.