I have a single table of data named RDSLPDSL. I am trying to calculate two columns based on two measures I am creating from the table.
Count of RDSL Marker for 1 =
CALCULATE(
COUNT('RDSLPDSL'[RDSL Marker]),
'RDSLPDSL'[RDSL Marker] IN { 1 }
)
I am using the above code as a measure to look for values only with 1 in it in the RDSL Marker column.
RDSL % = DIVIDE([Count of RDSL Marker for 1], COUNTROWS(RDSLPDSL))
Then I created a column using the above code to divide the rows with 1 by the total number of rows in the table.
I am doing the same for another column with PDSL. It is as follows:
Count of PDSL Marker for 1 =
CALCULATE(
COUNT('RDSLPDSL'[PDSL Marker]),
'RDSLPDSL'[PDSL Marker] IN { 1 }
)
PDSL % = DIVIDE([Count of PDSL Marker for 1], COUNTROWS(RDSLPDSL))
But when I do this calculation, I am getting an error for circular dependency detected and not getting the final output even though the same code worked for the previous column.
I tried COUNTAX directly instead of using CALCULATE but that brings up the same error too.
I also tried using measures instead of custom column which seems to remove the error but the output is not what I expect and is incorrect.
Any help for the same would be highly appreciated.
Related
I'm trying to calculate the running total of a count using values from the previous date, and while my previous value calculation is correct, the running total isn't working properly. Instead of doing a running total, it's giving the same values as the previous value measure.
Sample of Data:
Example of Data
Here's the DAX that I've tried using - any help would be greatly appreciated!
Normal Values: DISTINCTCOUNTNOBLANK(Item A)
Previous Value #1: CALCULATE(Normal Values, TOPN(1, FILTER(ALLSELECTED(Table), Table[Date] < MAX(Table[Date])), Table[Date], DESC))
Previous Value #2: CALCULATE(Normal Values, FILTER(ALLSELECTED(Table), Table[DateRank] = (MAX(Table[DateRank]) - 1)
Running Total Attempt #1: CALCULATE(Previous Value, FILTER(ALL(Table), Table[Date] < MAX(Table[Date]))
Running Total Attempt #2: CALCULATE(Previous Value, FILTER(ALLSELECTED(Table), Table[Date] < MAX(Table[Date]))
Running Total Attempt #3: CALCULATE(Previous Value, FILTER(ALLSELECTED(Table[Date]), ISONORAFTER(Table[Date], MAX(Table[Date]), DESC)))
Running Total Attempt #4:
var PreviousDay1 = CALCULATE(Normal Values, TOPN(1, FILTER(ALLSELECTED(Table), Table[Date] < MAX(Table[Date])), Table[Date], DESC))
var RunningTotal = CALCULATE(PreviousDay1, FILTER(ALL(Table), Table[Date] < MAX(Table[Date]))
return
Running Total
Note: both Previous Value #1 and #2 give the same exact results and are working as expected, I just tried different calculations to see if the structure was the issue. There are also no filters placed on the workbook, so it's not an issue with filters or other charts being selected on the page.
I have also tried both Previous Value #1 and #2 in all of the four Running Total DAX calculations above, but none seem to work. That being said, if I substitute "Previous Values" for "Normal Values" in the calculations, they running total calculation works, so it appears that the issue is with the previous values DAX being nested inside of the running total DAX.
I'm trying to complete something which should be quite simple but for the life of me, I can't work it out.
I'm trying to calculate the difference between 2 rows that share the same 'Scan type'.
I have attached a photo showing sample data from production. We run a scan and depending on the results of the scan, it's assigned a color.
I want to find the difference in Scan IDs between each Red scan.
Using the attached Photo of Sample data, I would expect a difference of 0 for id 3. A difference of 1 for id 4 and a difference of 10 for id 14.
I have (poorly) written something that works based on the maximum value from the scan id.
I have also tried following a few posts to see if I can get it to work..
var _curid= MAX(table1[scanid])
var _curclueid = MAX(table1[scanid])
var _calc =CALCULATE(SUM(TABLE1[scanid],FILTER(ALLSELECTED(table1[scanid]),table1[scanid]))
return if(_curid-_calc=curid,0,_curid-_calc)
Edit;
Forgot to mention I have checked threads;
57699052
61464745
56703516
57710425
Try the following DAX and if it helps then accept it as the answer.
Create a calculated column that returns the ID where the colour is Red as follows:
Column = IF('Table'[Colour] = "Red", 'Table'[ID])
Create another column as following:
Column 2 =
VAR Colr = 'Table'[Colour]
VAR SCAN = 'Table'[Scan ID]
VAR Prev_ID =
CALCULATE(MAX('Table'[Column 2]),
FILTER('Table', 'Table'[Colour] = Colr && 'Table'[Scan ID] < SCAN))
RETURN
'Table'[Column] - Prev_ID
Output:
EDIT:-
If you want your first value(ID3) to be 0 then relace the RETURN line with the following line:
IF(ISBLANK(Prev_ID) && 'Table'[Colour] = "Red", 0, 'Table'[Column] - Prev_ID )
This will give you the following result:
I was able to find the “2”'s per client with the following formula (Column L).
TotalSimultaneous2 =
IF(Data[Column1]=2,1,0)+
IF(Data[Column2]=2,1,0)+
IF(Data[Column3]=2,1,0)+
IF(Data[Column4]=2,1,0)+
IF(Data[Column5]=2,1,0)+
IF(Data[Column6]=2,1,0)+
IF(Data[Column7]=2,1,0)+
IF(Data[Column8]=2,1,0)+
IF(Data[Column9]=2,1,0)+
IF(Data[Column10]=2,1,0)
Now I need help finding the total amount of columns that contain at least one “2” column N.
In the example below, it would be 7, and that number is coming from the count of all the columns in green since they have at least one “2”.
I can find the simultaneous one. For example, Client4 has the max amount of “2” at the same time, which is 6, but I am having a hard time adding that one “2” from Column10 from Client10 and showing that the number of columns containing a “2” is 7 instead of 6.
Anything helps. Feel free to ask for further clarification, and I will try my best.
You can try this below measure. Here I have added 3 columns but you can add as many as you have-
count_column_with_2 =
CALCULATE(
DISTINCTCOUNT(your_table_name[col1]),
FILTER(your_table_name, your_table_name[col1] = 2)
)
+
CALCULATE(
DISTINCTCOUNT(your_table_name[col2]),
FILTER(your_table_name, your_table_name[col2] = 2)
)
+
CALCULATE(
DISTINCTCOUNT(your_table_name[col3]),
FILTER(your_table_name, your_table_name[col3] = 2)
)
I have a column with a formula which reads:
Utilisation (Excl. Time-off) = Utilisation_Excl_Timeoff[Billable Hours]/(Utilisation_Excl_Timeoff[Available Hours] - Utilisation_Excl_Timeoff[Timeoff Hours (Excl. Public)])
It gives me a "NaN" error in my calculated column for some of the cells due to divide by zero.
I would like to replace the NaN with a 0% instead so that the column displays correctly in my matrix chart.
Take a look at the DIVIDE function (https://msdn.microsoft.com/en-us/library/jj677276.aspx).
This is a 'safe divide` function with the option to return an alternative value if the division returns an error.
-JP
If you are looking for solution in M, then add conditional column:
Set up Otherwise temporarily to dividend column, here I took [Value] column. After doing this change in editor [Value] to [Value]/[Units]. This returns null wherever Units is 0. You may change returned output to 0% according to thy wish.
Alternatively, you can do it as well by adding this step:
= Table.AddColumn(#"Previous Step", "UnitPrice", each if [Units] = 0 then "0%" else [Value]/[Units])
IFERROR(value, value_if_error) function can do this. MSDN
Utilisation (Excl. Time-off) = IFERROR(Utilisation_Excl_Timeoff[Billable Hours]/(Utilisation_Excl_Timeoff[Available Hours] - Utilisation_Excl_Timeoff[Timeoff Hours (Excl. Public)]), 0)
I have a table made using Python 2.7 and tktable v1.1 that looks like the following:
class GUI (Tkinter.Tk):
self.testTable = tktable.Table(self, rows = 30, cols = 30, state='disabled',titlecols=1,titlerows=1, \
selectmode='extended', variable=self.tktableArray, selecttype='row', colstretchmode='unset', \
maxwidth=500, maxheight=190, xscrollcommand = self.HScroll.set, yscrollcommand = self.VScroll.set) # Create the results table
self.testTable.grid(column= 2, row = 6, columnspan = 4) # Add results table to the grid
Irrelevant code was left out in order to not throw a wall of code up. My desire here is to size the column widths independently for each column. For instance in column 0 I have only 3 digit numbers and in column 1 I have a 10 character word. I know that I could use
self.testTable.configure(colwidth=10)
to set the widths of the columns but that applies to all columns. Is there a way to do this on a per-column basis? And even better, is there a way to make the column widths fit to the contents of the column? Any help is appreciated.
I've never used a tktable, but a quick read of the tktable documentation shows there's a width() method on the table object. Have you tried that?
# set width of column 0 to 3, column 1 to 10
self.testTable.width(0,3,1,10)
The right answer is:
columnwidth={'0':7,'1':12,'2':20,'3':35,'4':15,'5':15,'6':22}
self.table.width(**columnwidth)