March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
146 | |
97 | |
79 | |
69 |