Forum Discussion
sqldev2017
7 years agoMicrosoft Employee
Help with Simple DAX formula
I am doing something like this -
PreviousMonth = FORMAT(CALCULATE(MIN(DimDate[Month]), FILTER(DimDate, DimDate[Month_Year] = [SelectedMonthYear]) ), "String")
- Min(DimDate[Month]) returns a string ... I can see it returns the right string.
But when i now use this calculated "Measure" (PreviousMonth) - in another formula , the result of that formula returns BLANK .... When I replace this measure (in that other formula), with a hard coded string , that formula returns the right result !
What am i doing wrong ?
I have tried every kind of thing, it doesn't work !
Try storing the MEASURE value in a variable first
Revenue = VAR myMEASURE = [MonthYear] RETURN CALCULATE ( SUM ( fact[Revenue] ), FILTER ( fact, fact[fiscalMonth] = myMEASURE ) )
7 Replies
- MFelixSuper User
Hi sqldev2017,
What do you want to use this measure for? what is the context and calculation you arre making on the other measure where this one is used?
Regards,
MFelix
- sqldev2017Microsoft Employee
I simply want to return one string value from a table, based on a filter.... That filter will always return one string value (for that table).
I understand CALCULATE is only for numeric measures...
But in this instance CALCULATE also seems to return a string !
- MFelixSuper UserHi sqldev2017,
Calculate is not only for numeric it can be used in very different ways and the result will be variable text, numbers, etc.
You say in your post that you want to use the measure you calculated in another measure what is exactly your needs? Can you share sample data, setup expected result.
Regards
Mfelix