I am getting an error if adding text "" as output of the IF function
The DAX code works OK if I add a number as the output of the IF condition, but I need to show the text "Below target" and "Above target"
How to fix this measure and have a text "" as an output of a SUMX function?
Target = SUMX(SUMMARIZE('Table1','Table1'[Customer ID], 'Table1'[Sales], "MaxResut",MAX('Table1'[Sales])), IF([MaxResult]>=1000,"Above target","Below target"))
Your DAX is trying to sum a column of text values that are either "Above target" or "Below target". This throws an error because it doesn't make sense to add text values like that.
It's not clear what you are actually trying to do but if you wanted to test the sum of the max results, then this might make sense:
Target =
IF (
SUMX (
SUMMARIZE (
'Table1',
'Table1'[Customer ID],
'Table1'[Sales],
"MaxResut", MAX ( 'Table1'[Sales] )
),
[MaxResult]
) >= 1000,
"Above target",
"Below target"
)
This does the comparison after summing rather than summing text values.
Related
I'm quite new in using DAX in PowerBi and I need to perform the following dax function:
Latest Detailed =
LOOKUPVALUE (
EXAM_REPORT[ACTUAL_EXAM_DATE],
EXAM_REPORT[CES EXAM.EXAM_TYPE_SR_KEY],
EXAM_REPORT[CES EXAM.EXAM_TYPE_SR_KEY] = 2,
EXAM_REPORT[CES EXAM.EXAM_SIGNOFF_DATE],
ISBLANK ( EXAM_REPORT[CES EXAM.EXAM_SIGNOFF_DATE] ) = FALSE,
EXAM_REPORT[ASSET_GUID],
[ASSET_GUID] = [ASSET_GUID]
)
Unfortunately I keep getting this error:
Function 'LOOKUPVALUE' does not support comparing values of type Number with values of type True/False. Consider using the VALUE or FORMAT function to convert one of the values.
I’ve tried converting everything to strings and also tried VALUE as well, but nothing changes.
Could you please help me? How can I do in a way that all the values share the same datatype?
LOOKUPVALUE has a different signature than what you are using:
LOOKUPVALUE(
<result_columnName>,
<search_columnName>,
<search_value>
[, <search2_columnName>, <search2_value>]…
[, <alternateResult>]
)
Your Code:
LOOKUPVALUE(
<result_columnName>,
<search_columnName>,
<search_columnName> = <search_value>
)
And FALSE must be FALSE(), but the condition is inappropriate anyway.
Someone can help me?
I need do filter in my dash basead in multiples values in the filter, if usuary selected two informations it need to apper, if selected one, one information, if no seletected, show everthing.
My code:
Max Value =
VAR SUC = CONCATENATEX (FILTER(TABLE[COLUMN]; CONCATENATE("""";CONCATENATE(TABLE[COLUMN]);""""));"; ")
VAR SOLUTION = CALCULATE(SUM(TABLE[COLUMN2]);
--ANOTHER FILTERS--
FILTER(ALL(TABLE); TABLE[COLUMN3] = VALUE;
--ERROR--
IF(ISFILTERED(TABLE[COLUMN]); TABLE[COLUMN] IN {SUC} --ONE VALUE OK, TWO VALUES SELETECTED= NULL--; TABLE[COLUMN] IN ALLSELETECTED(TABLE[COLUMN]) --ALL VALUES - OK--)
RETURN SOLUTION
-- TEXT -- IS A COMMENTARY
IF (Calender[income]<7000,"Silvercard", IF (Calender[income]<90000,"Goldcard","NoCard")) Can u give solution to this?? Can anyone tell me the error.
Shows above error in POWERBI i.e. DAX comparsion operations do not support comparing values of type text with values of type integer
The error is on the data type of your column Calender[income].
It is best practice to change the column data type to whole number or decimal.
Also, what you can do but is not ideal is using VALUE to transform the text into a number.
CalculatedColumn =
IF (
VALUE ( Calender[income] ) < 7000,
"Silvercard",
IF ( VALUE ( Calender[income] ) < 90000, "Goldcard", "NoCard" )
)
In Google Sheets, how do I get the value of the first non-empty cell in the row 17 starting at column C forwards?
I'm looking at a similar issue and found solutions similar to this, that might work for you:
=INDEX(C17:17,MATCH(TRUE,C17:17<>"",0))
As I understand it, MATCH will find the position of the first element in C17:17 that it's different to "" (exactly, hence the 0) and index will retrieve the value from that same range.
try:
=INDIRECT(ADDRESS(17, INDEX(MIN(IF(C17:17<>"", COLUMN(C17:17), )))))
I found another way that works, but not nearly as elegant as player0's.
=INDEX( FILTER( (SORT(TRANSPOSE(C17:17),TRANSPOSE(COLUMN(C17:17)),FALSE)) , NOT( ISBLANK( (SORT(TRANSPOSE(C17:17),TRANSPOSE(COLUMN(C17:17)),FALSE)) ) ) ) , ROWS( FILTER( (SORT(TRANSPOSE(C17:17),TRANSPOSE(COLUMN(C17:17)),FALSE)) , NOT( ISBLANK( (SORT(TRANSPOSE(C17:17),TRANSPOSE(COLUMN(C17:17)),FALSE)) ) ) ) ) )
I put this together from two other answers on SO, one on how to reverse the cells in a row, and one on finding the last non-empty cell in a column.
So this formula reverses C17:17, but leaves it as a column:
=(SORT(TRANSPOSE(C17:17),TRANSPOSE(COLUMN(C17:17)),FALSE))
And then this result is used as the range, when finding the last non-blank value in a column, which would be the first non-blank from the original row.
(From Get the last non-empty cell in a column in Google Sheets)
I replaced A:A in the following, with the formula from just above.
=INDEX( FILTER( A:A ; NOT( ISBLANK( A:A ) ) ) ; ROWS( FILTER( A:A ; NOT( ISBLANK( A:A ) ) ) ) )
The result is not very pretty but it worked.
Forced with computation speed.
The next formula is the most productive:
=MATCH(FALSE;MAP(5:5;LAMBDA(val;ISBLANK(val)));0)
Description:
Convert the analysed row to the array with “True” and “False” values.
If the cell is not empty -> True, else False. Then find the first “False” element in the array.
Function “ISBLANK” is used to check empty cells
NOT(ISBLANK(val)
Function “MAP” applies the “ISBALNK” to each cell in the row and returns an array.
MAP(5:5;LAMBDA(val;NOT(ISBLANK(val))))
MUTCH finds the index of the first non-empty cell
I'm new to PowerBi and i'm running into the following problem:
Weeknum + year are not shown in the correct order. See the following screenshots:
I've concatenate weeknumber with year based on a column called "PublishDate"
This is my dax query for weeknum:
Weeknum = YEAR ( [PublishDate] ) & "" & WEEKNUM ( [PublishDate], 2 )
I do notice that 1 till 9 are not shown with a 0 infront of it. Could this be causing this?
I agree with getting the '0' in the right place. Once you change the data type from text to a number, if that '0' in't there, it will be out of order as well.
I prefer editing the query and changing the data type from the beginning:
Finding the column that needs a data type change and modifying it there:
[
You can change it from text to whole number.
The problem is that the values are being sorted in alphabetical order, because they are of datatype text. So yes, the fact that '9' does not have a '0' in front of it, does cause your problem. You can solve this by changing the format of the WEEKNUM function like this (also you do not need & "" &):
Weeknum = YEAR ( [PublishDate] ) & FORMAT(WEEKNUM ( [PublishDate], 2 ),"00")