Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
eddd83
Resolver I
Resolver I

Handling multiple values when a single value is needed

What happens when you select multiple months and/or years:

visual fail.png

 

The resulting error message:

 

 fail message.png

 

 

the measure:

 

Actuals less Forecast = 
VAR Today =
	MAX ( 'DateTable'[Date] ) 
VAR Month_End =
	EOMONTH ( TODAY (), 0 )
VAR SupplierProjMinusForecast =
	[Supplier Projected] - [Supplier Forecast]
VAR Year_Row = 
	VALUES ( 'DateTable'[Year] )
VAR Year_Today = 
	YEAR ( TODAY () )
VAR Month_Row =
	VALUES ( 'DateTable'[MonthNumber] )
VAR Month_Today =
	MONTH ( TODAY () )
VAR Date_Compare =	
	IF(
		OR(
			Year_Row < Year_Today,
			AND(
				Year_Row = Year_Today,
				Month_Row <= Month_Today
			)
		),
		SupplierProjMinusForecast,
		IF(
			Today <= Month_End, 
			//in Richard's volume report, user can select only a year or a quarter, so month check above fails. To avoid calculating very misleading variance, calc is limited to only producing a result if date selection is up to the end of the current month
			SupplierProjMinusForecast
		)
	)
Return Date_Compare

This line seems to be causing all of the problems when multiple months are selected.

 

VAR Month_Row =
	VALUES ( 'DateTable'[MonthNumber] )

 

How would I modify my measure, so that the visual functions properly?

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @eddd83,

Due to I could not reproduce your problem, could you please offer me some sample file to have a test or share the pbix file if possible?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-danhe-msft
Employee
Employee

Hi @eddd83,

Due to I could not reproduce your problem, could you please offer me some sample file to have a test or share the pbix file if possible?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I end up changing Year_Row and Month_Row from VALUES to MAX.

 

VAR Year_Row = 
	VALUES ( 'DateTable'[Year] )
VAR Year_Today = 
	YEAR ( TODAY () )
VAR Month_Row =
	VALUES ( 'DateTable'[MonthNumber] )

 

This seemed to produce the desired effect for my report.

Hi @eddd83,

It's pleasant that your problem has been solved, could you please mark your reply as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.