Power BI DAX circular dependency was detected between two calculated columns - powerbi

I have a calculated column that works as intended for current year calculations called RTP. For reference here is the code:
RTP =
VAR ActualPM = AND(AND(
'Opex Summary'[Date] >= CALCULATE(STARTOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 1)),
'Opex Summary'[Date] <= CALCULATE(ENDOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 1))
),'Opex Summary'[Flag] <> "Budget")
VAR ActualPM_Name = FORMAT(CALCULATE(MIN(Dates[Mth]),FILTER(ALL(Dates),Dates[Month Offset] = 1)) ,"mm/yyyy")
VAR ActualPM1 = AND(AND(
'Opex Summary'[Date] >= CALCULATE(STARTOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 2)),
'Opex Summary'[Date] <= CALCULATE(ENDOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 2))
),'Opex Summary'[Flag] <> "Budget")
VAR ActualPM1_Name = FORMAT(CALCULATE(MIN(Dates[Mth]),FILTER(ALL(Dates),Dates[Month Offset] = 2)) ,"mm/yyyy")
VAR ActualPM2 = AND(AND(
'Opex Summary'[Date] >= CALCULATE(STARTOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 3)),
'Opex Summary'[Date] <= CALCULATE(ENDOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 3))
),'Opex Summary'[Flag] <> "Budget")
VAR ActualPM2_Name = FORMAT(CALCULATE(MIN(Dates[Mth]),FILTER(ALL(Dates),Dates[Month Offset] = 3)) ,"mm/yyyy")
VAR BudgetPM = AND(AND(
'Opex Summary'[Date] >= CALCULATE(STARTOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 1)),
'Opex Summary'[Date] <= CALCULATE(ENDOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 1))
),'Opex Summary'[Flag] = "Budget")
VAR BudgetPM_Name = FORMAT(CALCULATE(MIN(Dates[Mth]),FILTER(ALL(Dates),Dates[Month Offset] = 1)) ,"mm/yyyy")
VAR ActualPM_PY = AND(AND(
'Opex Summary'[Date] >= CALCULATE(STARTOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 13)),
'Opex Summary'[Date] <= CALCULATE(ENDOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 13))
),'Opex Summary'[Flag] <> "Budget")
VAR ActualPM__PYName = FORMAT(CALCULATE(MIN(Dates[Mth]),FILTER(ALL(Dates),Dates[Month Offset] = 13)) ,"mm/yyyy")
RETURN
SWITCH(TRUE(),
ActualPM, "CY Act (" & ActualPM_Name & ")",
ActualPM1, "CY Act (" & ActualPM1_Name & ")",
ActualPM2, "CY Act (" & ActualPM2_Name & ")",
BudgetPM, "CY Bud (" & BudgetPM_Name & ")",
ActualPM_PY, "PY Act (" & ActualPM__PYName & ")",
"EXCLUDE"
)
I am attempting to create a similar year to date calculated column called RTP YTD. This is providing me the following error:
A circular dependency was detected: Opex[RTP YTD], Opex[RTP], Opex[RTP YTD]
The code that creates the error is below:
RTP YTD =
VAR ActualYTD1 = AND(AND(
'Opex Summary'[Date] >= CALCULATE(STARTOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 13)),
'Opex Summary'[Date] <= CALCULATE(ENDOFMONTH('Opex Summary'[Date]),FILTER(ALL(Dates), Dates[Month Offset] = 1))
),'Opex Summary'[Flag] <> "Budget")
VAR ActualYTD_Name1 = FORMAT(CALCULATE(MIN(Dates[Date]),FILTER(ALL(Dates),Dates[Month Offset] = 1)) ,"mm/yyyy")
RETURN
SWITCH(TRUE(),
ActualYTD1, "YTD Act (" & ActualYTD_Name1 & ")",
"EXCLUDE"
)

Related

I want to draw many shapes, but don't know how to use the class array

paint shape 1, but paint shape 2 , shape 1 is clear ..
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Ismousedown = true;
LocationXY = e.Location;
mousedownR = (int)(Math.Round(Math.Sqrt(Math.Pow(LocationXY.X - 250, 2) + Math.Pow(LocationXY.Y - 250, 2)), 2));
// label2.Text = mousedownstarAngle.ToString();
if (e.X >= 250)
{
gocanphal = (int)(270 - Math.Round(180 * -Math.Asin((e.Y - 250) / Math.Sqrt(Math.Pow(250 - e.X, 2) + Math.Pow(e.Y - 250, 2))) / Math.PI, 2));
}
if (e.X < 250)
{
gocanphal = (int)(90 + Math.Round(180 * (-Math.Asin((e.Y - 250) / Math.Sqrt(Math.Pow(250 - e.X, 2) + Math.Pow(e.Y - 250, 2)))) / Math.PI, 2));
}
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (Ismousedown == true)
{
LocationX1Y1 = e.Location;
if (e.X >= 250)
{
gocmo = (int)(270 - Math.Round(180 * -Math.Asin((LocationX1Y1.Y - 250) / Math.Sqrt(Math.Pow(250 - LocationX1Y1.X, 2) + Math.Pow(LocationX1Y1.Y - 250, 2))) / Math.PI, 2));
}
if (e.X < 250)
{
gocmo = (int)(90 + Math.Round(180 * -Math.Asin((LocationX1Y1.Y - 250) / Math.Sqrt(Math.Pow(250 - LocationX1Y1.X, 2) + Math.Pow(LocationX1Y1.Y - 250, 2))) / Math.PI, 2));
}
Refresh();
mouseupR = (int)(Math.Round(Math.Sqrt(Math.Pow(LocationX1Y1.X - 250, 2) + Math.Pow(LocationX1Y1.Y - 250, 2)), 2));
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (Ismousedown == true)
{
LocationX1Y1 = e.Location;
Ismousedown = false;
mouseupR = (int)(Math.Round(Math.Sqrt(Math.Pow(e.X - 250, 2) + Math.Pow(e.Y - 250, 2)), 2));
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(penn, 250, 250, 250, 0);
var g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
var center = new Point(250, 250);
var innerR = mouseupR;// xa or gan diem dau
//var thickness = 30;// do day
var startAngle1 = gocanphal + 90;// diem bat dau
var arcLength1 = gocmo - gocanphal;// diem end
var outerR = mousedownR;
// var innerR = mousedownR - mouseupR;
var outerRect = new Rectangle
(center.X - outerR, center.Y - outerR, 2 * outerR, 2 * outerR);//center.Y - outerR
var innerRect = new Rectangle
(center.X - innerR, center.Y - innerR, 2 * innerR, 2 * innerR); // center.X - innerR
// using (var p = new GraphicsPath())
e.Graphics.FillEllipse(Brushes.White, 150, 150, 5, 5);
GraphicsPath p = new GraphicsPath();
p.AddArc(outerRect, startAngle1, arcLength1);
p.AddArc(innerRect, startAngle1 + arcLength1, -arcLength1);
p.CloseFigure();
g.DrawPath(Pens.Blue, p);
}
}
}
Want to draw more pictures and save

Compare Selected quarter to last quarter in DAX, even when i select Q1 it should compare with last year's Q4

Hi i am working on a solution in DAX where i have to find customers not ordered in current Quarter compared to its last quarter, i am able to compare Q2, Q3 and Q4 but when i select Q1 i get no value. if i select it should compare with Q4 of last year
how this can be achieved?
Thanks
this was my original question
get new customers compared to last month in dax power bi
with a little bit of tinkering i am here now
Customers Not ordered This Quarter =
VAR ThisQuarter =
SELECTEDVALUE( DailyReport[DateCreated].[QuarterNo])
VAR ThisYEAR =
SELECTEDVALUE(DailyReport[DateCreated].[Year])
VAR SelectedSupplier =
SELECTEDVALUE(DailyReport[SupplierName])
VAR LastQuarter = ThisQuarter - 1
VAR CustomersThisQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = ThisQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = ThisYEAR),
"C1", DailyReport[VenueName]
)
)
VAR CustomersLastQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = LastQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = ThisYEAR),
"C1", DailyReport[VenueName]
)
)
VAR T1 =
EXCEPT(CustomersLastQuarter, CustomersThisQuarter )
RETURN
CONCATENATEX( T1, [C1], UNICHAR(10), [C1], ASC)
it should compare with the last year's Q4 when i select Q1 in current year
You really need a date table. I have written the code below blind but it should work.
Customers Not ordered This Quarter =
VAR ThisQuarter =
SELECTEDVALUE( DailyReport[DateCreated].[QuarterNo])
VAR ThisYEAR =
SELECTEDVALUE(DailyReport[DateCreated].[Year])
VAR SelectedSupplier =
SELECTEDVALUE(DailyReport[SupplierName])
VAR LastQuarter = IF(ThisQuarter = 1,4,ThisQuarter - 1)
VAR LastYear = IF(ThisQuarter = 1,ThisYEAR -1,ThisYEAR)
VAR CustomersThisQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = ThisQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = ThisYEAR),
"C1", DailyReport[VenueName]
)
)
VAR CustomersLastQuarter =
DISTINCT(
SELECTCOLUMNS(
FILTER( ALL( DailyReport ), DailyReport[DateCreated].[QuarterNo] = LastQuarter && DailyReport[SupplierName] = SelectedSupplier && DailyReport[DateCreated].[Year] = LastYEAR),
"C1", DailyReport[VenueName]
)
)
VAR T1 =
EXCEPT(CustomersLastQuarter, CustomersThisQuarter )
RETURN
CONCATENATEX( T1, [C1], UNICHAR(10), [C1], ASC)

Else If - Google Script

this script was working before on my Google Sheet, then all of a sudden, it stopped working. I notice that the first argument (if) is working, but all the codes after that is not working. Any ideas?
function onEdit(event) {
// assumes source data in sheet named Sheet1
// target sheet of move to named Sheet2
// test column with yes is col 7 or G
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Under Contract Response Form" && r.getColumn() == 7 && (r.getValue() == "Closed" || r.getValue() == "Expired" || r.getValue() == "Cancelled")) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Closed/Expired & Cancelled");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
s.deleteRow(row);
} else if(s.getName() == "Listing Response Form" && r.getColumn() == 7 && r.getValue() == "Pending" ) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Under Contract Response Form");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
s.deleteRow(row);
} else if(s.getName() == "Listing Response Form" && r.getColumn() == 7 && r.getValue() == "Cancelled" ) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Closed/Expired & Cancelled");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
s.deleteRow(row);
} else if(s.getName() == "Under Contract Response Form" && r.getColumn() == 7 && (r.getValue() == "Pre-list" || r.getValue() == "Withheld" || r.getValue() == "Coming Soon" || r.getValue() == "Active")) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Listing Response Form");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
s.deleteRow(row);
} else if(s.getName() == "Closed/Expired & Cancelled" && r.getColumn() == 7 && r.getValue() == "Pending" ) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Under Contract Response Form");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
s.deleteRow(row);
}
}
The script looks fine, so chances are that one or more sheets has been renamed, or columns inserted or deleted. Check the sheet names and look for things like leading or trailing spaces. Also ensure that the values that should trigger row move appear in column G.
You can make row moves more robust by using column names instead of column numbers. See the moveRowsFromSpreadsheetToSpreadsheet_ script.

Power BI couting

I'm trying to create a measure that will count values from the table below. How can I count projects that have at least one task and date and how can I count projects that have two tasks and dates?
Bonus question: how can I count projects that have at least one task and no date (null) and how can I count projects with two tasks done and no dates?
Here below 4 measures is for you-
1.
one_one =
var count_task_1 = IF(min(project_count[task 1]) <> BLANK() && MIN(project_count[date 1]) <> BLANK(),1,0)
var count_task_2 = IF(min(project_count[task 2]) <> BLANK() && MIN(project_count[date 2]) <> BLANK(),1,0)
var count_task_3 = IF(min(project_count[task 3]) <> BLANK() && MIN(project_count[date 3]) <> BLANK(),1,0)
RETURN
IF(
(count_task_1+count_task_2+count_task_3) >= 1,
1,
0
)
2.
two_two =
var count_task_1 = IF(min(project_count[task 1]) <> BLANK() && MIN(project_count[date 1]) <> BLANK(),1,0)
var count_task_2 = IF(min(project_count[task 2]) <> BLANK() && MIN(project_count[date 2]) <> BLANK(),1,0)
var count_task_3 = IF(min(project_count[task 3]) <> BLANK() && MIN(project_count[date 3]) <> BLANK(),1,0)
RETURN
IF(
(count_task_1+count_task_2+count_task_3) >= 2,
1,
0
)
3.
one_no_date =
var count_task_1 = IF(min(project_count[task 1]) <> BLANK() && MIN(project_count[date 1]) = BLANK(),1,0)
var count_task_2 = IF(min(project_count[task 2]) <> BLANK() && MIN(project_count[date 2]) = BLANK(),1,0)
var count_task_3 = IF(min(project_count[task 3]) <> BLANK() && MIN(project_count[date 3]) = BLANK(),1,0)
RETURN
IF(
(count_task_1+count_task_2+count_task_3) >= 1,
1,
0
)
4.
two_no_date =
var count_task_1 = IF(min(project_count[task 1]) <> BLANK() && MIN(project_count[date 1]) = BLANK(),1,0)
var count_task_2 = IF(min(project_count[task 2]) <> BLANK() && MIN(project_count[date 2]) = BLANK(),1,0)
var count_task_3 = IF(min(project_count[task 3]) <> BLANK() && MIN(project_count[date 3]) = BLANK(),1,0)
RETURN
IF(
(count_task_1+count_task_2+count_task_3) >= 2,
1,
0
)
Here is the output-
You can do your other necessary calculation using these logics

How to set selected segment background color using HMSegmentedControl in Swift 3.0

How can i achieve this style using HMSegmentedControl when the index is selected.Please help me how can i achieve this in swift 3.0 ......if it is possible
Here is my Code:
func setupSegementCategory(){
segmentCategory.sectionTitles = ["home","about","contract","home","about","contract"]
segmentCategory.backgroundColor = #colorLiteral(red: 0.7683569193, green: 0.9300123453, blue: 0.9995251894, alpha: 1)
segmentCategory.translatesAutoresizingMaskIntoConstraints = false
segmentCategory.selectionIndicatorLocation=HMSegmentedControlSelectionIndicatorLocation.down
segmentCategory.isVerticalDividerEnabled=false
segmentCategory.selectedSegmentIndex=0
segmentCategory.selectionIndicatorColor = UIColor.white
segmentCategory.segmentWidthStyle = HMSegmentedControlSegmentWidthStyle.dynamic
segmentCategory.titleTextAttributes = [
NSForegroundColorAttributeName : #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1),
NSFontAttributeName : UIFont.systemFont(ofSize: 17)
]
segmentCategory.backgroundColor=Constant.GlobalConstants.kColor_blue
segmentCategory.selectedTitleTextAttributes = [
NSFontAttributeName : UIFont.systemFont(ofSize: 17),
NSForegroundColorAttributeName :UIColor(red:0.74, green:0.70, blue:1.00, alpha:1.0)
]
segmentCategory.addTarget(self, action:#selector(segmentedControlValueChanged(sender:)), for: .valueChanged)
}
func segmentedControlValueChanged(sender: UISegmentedControl) {
let sortedViews = sender.subviews.sorted( by: { $0.frame.origin.x < $1.frame.origin.x } )
for (index, view) in sortedViews.enumerated() {
if index == sender.selectedSegmentIndex {
view.tintColor = UIColor.red
} else {
view.tintColor = UIColor.lightGray
}
}
}
There's currently no way to get that style in HMSegmentedControl.