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 September 15. Request your voucher.
Hi All,
I have below mentioned data table, I need to create a comparison between current year spend vs. previous year spend based on the multiple value selected in the dynamic filter.
DAX queries created so far:-
Data1 and Data2
Period Table
Dynamic Filter & Output
Solved! Go to Solution.
Hi @Saibal_78
First, add a column with this code to convert your period to date format:
Date =
DATE ( LEFT ( 'Table'[Period], 4 ), RIGHT ( 'Table'[Period], 2 ), 01 )
Then use this Measure to find last year amount:
Previous Period Spend =
CALCULATE (
SUM ( 'Table'[Spend] ),
REMOVEFILTERS ( 'Table'[Period] ),
SAMEPERIODLASTYEAR ( 'Table'[Date] )
)
For Current Period Spend, you don't need to use Measure. Just add the spend column to the card visual.
Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Not working, it's showing full year spend
I see the issue is I have selected Period, I should have selected Date in the slicer instead of Period, Thanks
yes 202101 and 202102
Try this:
Previous Period Spend =
CALCULATE (
SUM ( 'Table'[Spend] ),
SAMEPERIODLASTYEAR ( 'Table'[Date] )
)
Hi @Saibal_78
First, add a column with this code to convert your period to date format:
Date =
DATE ( LEFT ( 'Table'[Period], 4 ), RIGHT ( 'Table'[Period], 2 ), 01 )
Then use this Measure to find last year amount:
Previous Period Spend =
CALCULATE (
SUM ( 'Table'[Spend] ),
REMOVEFILTERS ( 'Table'[Period] ),
SAMEPERIODLASTYEAR ( 'Table'[Date] )
)
For Current Period Spend, you don't need to use Measure. Just add the spend column to the card visual.
Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
User | Count |
---|---|
15 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |