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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Result change according to the selected period

I would like to create a report where depending on the choice of the segment defined, the result can change.

For this, I created a 'Choice period' table. There is a column called "PeriodIndicator" and the data is as follows: "Annual, Half-yearly, Quarterly".

I also created a measure to define the periods:
Period =
var Annual= DATESINPERIOD('DimDate'[Date],MAX('DimDate'[Date]),-1,YEAR)
var Half-yearly = DATESINPERIOD('DimDate'[Date],MAX('DimDate'[Date]),-6,MONTH)
var Quarterly = DATESINPERIOD('DimDate'[Date],MAX('DimDate'[Date]),-4,MONTH)


return
SWITCH(
SELECTEDVALUE('ChoicePeriod'[PeriodIndicator]),
"Annual", Annual,
"Semi-annual", Semi-annual,
"Quarterly",Quarterly
)

I have created the following measure which is based on
[M] = the sum of the amounts spent

M Score =
var annual =
SWITCH(
TRUE(),
[M] <= 1000, "1",
[M] <= 2000, "2",
[M] <= 3000, "3",
[M] < 4000, "4",
[M] >= 4000, "5"
)
var semi-annual =
SWITCH(
TRUE(),
[M] <= 500, "1",
[M] <= 1000, "2",
[M] <= 1500, "3",
[M] < 2000, "4",
[M] >= 2000, "5"
)
var quarterly =
SWITCH(
TRUE(),
[M] <= 250, "1",
[M] <= 500, "2",
[M] <= 750, "3",
[M] < 1000, "4",
[M] >= 1000, "5"
)

return
SWITCH(
SELECTEDVALUE('ChoicePeriod'[Period]),
"Annual", annual,
"Semi-annual", semi-annual,
"Quarterly", quarterly,
"Monthly", monthly,
"Decade", decade
)

But it doesn't work, when I select, nothing is displayed

1 REPLY 1
NickolajJessen
Solution Sage
Solution Sage

I'm a little confused about how your measures are connected and what values you have in your ChoicePeriod table. But here is my best guess

You period measure returns a table (multiple date values - lets say 120 days for a 4 month period)

Period =
var Annual= DATESINPERIOD('DimDate'[Date],MAX('DimDate'[Date]),-1,YEAR)
var Half-yearly = DATESINPERIOD('DimDate'[Date],MAX('DimDate'[Date]),-6,MONTH)
var Quarterly = DATESINPERIOD('DimDate'[Date],MAX('DimDate'[Date]),-4,MONTH)


return
SWITCH(
SELECTEDVALUE('ChoicePeriod'[PeriodIndicator]),
"Annual", Annual,
"Semi-annual", Semi-annual,
"Quarterly",Quarterly
)

 

The last part of your M-score uses SELECTEDVALUE on the period measure, which only return a value, if a ONE value is selected. And 120 is more than 1, so it displays blank.

SWITCH(
SELECTEDVALUE('ChoicePeriod'[Period]),
"Annual", annual,
"Semi-annual", semi-annual,
"Quarterly", quarterly,
"Monthly", monthly,
"Decade", decade

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.