The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I want to create a clustered column chart for YoY comparison where the current year data should be filtered based on month selection but for Previous year it should show entire fiscal year
NOTE : Fiscal year is April to March
Hi @Sanket03
Please try this:
First of all, add a new calculated table:
Table 3 =
SUMMARIZE(
SELECTCOLUMNS(
'Table',
"Y_M", FORMAT(
'Table'[Date],
"YYYY-MM"
)
),
[Y_M]
)
Then add a measure:
MEASURE =
VAR _Slicer_month =
VALUE ( MID ( SELECTEDVALUE ( 'Table 3'[Y_M] ), 6, 2 ) )
VAR _Slicer_year =
VALUE ( MID ( SELECTEDVALUE ( 'Table 3'[Y_M] ), 1, 4 ) )
RETURN
IF (
_Slicer_month >= 4,
IF (
MAX ( 'Table'[Date] )
>= DATE ( _Slicer_year - 1, 4, 1 )
&& MAX ( 'Table'[Date] )
< DATE ( _Slicer_year, _Slicer_month + 1, 1 ),
[Current]
),
IF (
MAX ( 'Table'[Date] )
>= DATE ( _Slicer_year - 2, 4, 1 )
&& MAX ( 'Table'[Date] )
< DATE ( _Slicer_year, _Slicer_month + 1, 1 ),
[Current]
)
)
You can change the [Current] into your own measure such as [Current Year] and [Prior Year].
Create a slicer with the Field [Y_M] from the 'Table 3', the result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks a lot for suggesting this solution.
My requirement is based on Year and Month Selection for e.g. If I select 2024 and July then I should get data from April to July 2024 and also the entire fiscal year of 2023
Unforuntely it didnt work as I want it to be displayed it in Clustered Column Chart for CY and PY. I tried using a reference Date table but I could only achieve below solution but this is not the actual ask.
Hi @Sanket03
Could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Sanket03
Please try this:
Here I create a set of sample:
Table:
Then add a calculated table:
Table 2 =
SELECTCOLUMNS(
GENERATESERIES(
YEAR(MIN('Table'[Date])) - 1,
YEAR(MAX('Table'[Date])),
1
),
"Fiscal Year", [Value] & "-" & [Value] + 1
)
Then add 2 measures:
CurrentYear =
VAR _start =
MID ( SELECTEDVALUE ( 'Table 2'[Fiscal Year] ), 1, 4 )
RETURN
CALCULATE (
SUM ( 'Table'[Values] ),
FILTER (
'Table',
'Table'[Date] >= DATE ( _start, 4, 1 )
&& 'Table'[Date]
< DATE ( _start + 1, 4, 1 )
)
)
PreviousYear =
VAR _start =
MID ( SELECTEDVALUE ( 'Table 2'[Fiscal Year] ), 1, 4 )
RETURN
CALCULATE (
SUM ( 'Table'[Values] ),
FILTER (
ALL ( 'Table' ),
'Table'[Date]
>= DATE ( _start - 1, 4, 1 )
&& 'Table'[Date] < DATE ( _start, 4, 1 )
)
)
Create a Clustered column chart:
Then you can drag the field 'Table'[Date] into the Filters on this visual in the filter pane:
When you filter the date, the [PreviousYear] will not be affected:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
25 | |
12 | |
8 | |
8 | |
7 |
User | Count |
---|---|
28 | |
13 | |
12 | |
12 | |
6 |