Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
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.
I have a requirement wherein client wants to see last 12 months data based on the selected Year and Month Name selection.
Suppose if I select 2023 in Year and Month Name as Jan, then it should show us the data from Jan 2023 to Feb 2022 i.e.12 months.
Any help is appreciated.
Thanks,
Alina
Solved! Go to Solution.
Hi @amehrosh ,
Please create measure with below dax formula:
Measure =
VAR cur_year =
SELECTEDVALUE ( 'Table 2'[Year] )
VAR cur_month =
SELECTEDVALUE ( 'Table 3'[Month] )
VAR _month =
SWITCH (
cur_month,
"Jan", 1,
"Feb", 2,
"Mar", 3,
"Apr", 4,
"May", 5,
"Jun", 6,
"Jul", 7,
"Aug", 8,
"Sep", 9,
"Oct", 10,
"Nov", 11,
"Dec", 12
)
VAR max_date =
DATE ( cur_year, _month, 1 )
VAR tmp =
DATESINPERIOD ( 'Table 4'[Date], max_date, -12, MONTH )
VAR cur_date =
SELECTEDVALUE ( 'Table'[Date] )
RETURN
IF ( cur_date IN tmp, 1 )
Add a matrix visual and add this measure to filter pane and apply:
For more details, please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @amehrosh ,
Please create measure with below dax formula:
Measure =
VAR cur_year =
SELECTEDVALUE ( 'Table 2'[Year] )
VAR cur_month =
SELECTEDVALUE ( 'Table 3'[Month] )
VAR _month =
SWITCH (
cur_month,
"Jan", 1,
"Feb", 2,
"Mar", 3,
"Apr", 4,
"May", 5,
"Jun", 6,
"Jul", 7,
"Aug", 8,
"Sep", 9,
"Oct", 10,
"Nov", 11,
"Dec", 12
)
VAR max_date =
DATE ( cur_year, _month, 1 )
VAR tmp =
DATESINPERIOD ( 'Table 4'[Date], max_date, -12, MONTH )
VAR cur_date =
SELECTEDVALUE ( 'Table'[Date] )
RETURN
IF ( cur_date IN tmp, 1 )
Add a matrix visual and add this measure to filter pane and apply:
For more details, please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi @amehrosh
it seems you expect a measure. How do you plan to showcase this measure? What context do you have, like axis, row/column of a visual?
measure to show in a matrix.
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 21 | |
| 14 | |
| 9 | |
| 5 | |
| 5 |