Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi Friends,
Range of values in SSAS tabular model.
i have table name 'Total' and column is [DiffDays] and values in column are like, 100, 200, 300, 400, 500. when i am writing same if statement in SSAS tabular model it's not supporting. Need help.
below query working in Power bi but not supporting in SSAS tabular model, need help on same below requirement which works in SSAS cube.
Range = if(total[DiffDays]<=100,"0-100",if(AND(total[DiffDays]>100,total[DiffDays]<=300),"101-300",if(AND(total[DiffDays]>300,total[DiffDays]<=500),"301-500","501-above")))
Thanks SKM
Solved! Go to Solution.
@Anonymous Are you trying to create a measure or calculated column in SSAS. If you trying to create a calculated column then it will work and i case you are trying to create a measure you need to wrap the column into aggregate function depends on your requirement
Something like this
Range =
VAR _datediff = MAX('total'[DiffDay])
RETURN
SWITCH(TRUE()
,_datediff<=100,"0-100"
,AND(_datediff>100,_datediff<=300),"101-300"
,AND(_datediff>300,_datediff<=500),"301-500"
,"501-above")
@Anonymous What is the error message that you are getting?
Please check the data type of DiffDays it should be whole number. You can try a switch statement as well
Range = SWITCH(TRUE()
,total[DiffDays]<=100,"0-100"
,AND(total[DiffDays]>100,total[DiffDays]<=300),"101-300"
,AND(total[DiffDays]>300,total[DiffDays]<=500),"301-500"
,"501-above")
@Anonymous
Thanks a lot, great help!!! 🙂
solution working as expected.
@Anonymous
need one more help, i was beginner and not able to write complex, below is the requirement.
table[month] values: 1,2,3,4,5,6,7,8,9,10,12.
in below query no other column mention on filter on month.
3MonthsDiffrnce = If(Login[month]>0 && Login[month]<4)
6MonthsDiffrnce = If(Login[month]>3 && Login[month]<7)
output: 1,2,3
output: 4,5,6.
would you please help.
@Anonymous Can you please explain in more detail. May be you can share some sample data with expected outcome. do you need a calculated column or measure
Apologies for half cooked information.
below is the table and data.
| date_time | DateDiff_Day | DateDiff_Month |
| 9/4/19 11:51 | 86 | 2 |
| 1/19/19 18:13 | 314 | 10 |
| 1/21/19 9:04 | 312 | 10 |
| 12/13/18 17:29 | 351 | 11 |
| 3/25/19 15:17 | 249 | 8 |
| 4/1/19 18:04 | 242 | 7 |
| 2/8/19 8:50 | 294 | 9 |
| 2/19/19 13:20 | 283 | 9 |
| 12/18/18 10:51 | 346 | 11 |
| 3/19/19 19:08 | 255 | 8 |
i want to write new measure based on datediff_month column to divide data into 4 parts as below
3months, 6months, 12month and 1 year
3months: 1,2,3
6months: 4,5,6
12months: 7,8,9,10,11,12.
1year: 1,2,3,4,5,6.....11,12.
for that i am writing measure as below.
3MonthsDiffrnce = If(LastLogin[Diffrnce]>0 && LastLogin[Diffrnce]<4).
this i am implementing in SSAS tabular cube. if possible please suggest anyother method to implement.
would you please help.
@Anonymous
Thanks a lot for support.
column date type is whole number, and i am using direct column from table.
in Switch statement, Value is considered as Calculated column or measure, it is not accepting direct column.
would you please help in another way.
Error: not showing column name when i am writing switch DAX. it is showing measure names
@Anonymous Are you trying to create a measure or calculated column in SSAS. If you trying to create a calculated column then it will work and i case you are trying to create a measure you need to wrap the column into aggregate function depends on your requirement
Something like this
Range =
VAR _datediff = MAX('total'[DiffDay])
RETURN
SWITCH(TRUE()
,_datediff<=100,"0-100"
,AND(_datediff>100,_datediff<=300),"101-300"
,AND(_datediff>300,_datediff<=500),"301-500"
,"501-above")
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 40 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 70 | |
| 68 | |
| 32 | |
| 27 | |
| 25 |