Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
All, I am new to Power BI
I have couple of measures for Current Month and Previous Month as below formula
I would like to tweak this formula or any other easy way to show Current Month Sales for the Selected Month in Slicer and the Previous Month to show the previous month or the month selected in Slicer
Current Month Sales = var current_month= MONTH(TODAY()) var current_year=YEAR(TODAY()) return
Use this DAX:
People often solve this issue by creating a calculated column like this:
Months Past = VAR __today = CONCATENATE(YEAR(TODAY()),FORMAT(MONTH(TODAY()),"0#")) * 1 VAR __date = CONCATENATE(YEAR([Date]),FORMAT(MONTH([Date]),"0#")) * 1 RETURN __today - __date
This will give you the number of months in the past, 0 is the current month, 1 is the previous month, etc.
Hi Greg
Thanks for this. I am not looking for another dimension in this case.
If I implement the custom column, I get only 1 row of value when I choose a Month from slicer
What I really need is, If I choose Feb from my Month Slice, I want to see Current Month Sales as Feb 2019 and Previous Month Sales as Jan 2019
If I choose March in my slicer, want to see Current Month Sales as March 2019 and Previous Month sales as Feb 2019
Thanks
Jogesh
You generally disconnect your slicer and use the calculated column in a measure for selection purposes, so think of starting your measures out like:
This Month = VAR __table = FILTER('Table',[Months Ago] = 0) RETURN SUMX(__table,[Value]) Last Month VAR __table = FILTER('Table',[Months Ago] = 1) RETURN SUMX(__table,[Value])
It's really difficult to answer precisely without example data and expected output, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |