Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hi Team,
In power bi i need one line and stacked column chart like it should show the previous month data if the date cross 12th of every month or before 12th it should should previous two months data for example current month is april and date is 15th so it should show me last six month data i.e. Mar, Feb, Jan, Dec, Nov, Oct and if it doesn't cross 12th then it should show the months i.e. - Feb, Jan, Dec, Nov, Oct, Sept. I have written a dax query which is something like this but i am getting an error that
'Measure'[PreviousMonths]: A table of multiple values was supplied where a single value was expected.
Dax Query -
Solved! Go to Solution.
Hello Everyone!!
Thanks for your responses and your time, really appreciate, but i have solved the issue by my own by using the below mention DAX query. But anyways, really thanks for your support.
Hello Everyone!!
Thanks for your responses and your time, really appreciate, but i have solved the issue by my own by using the below mention DAX query. But anyways, really thanks for your support.
Hi @rastoiyashu4 ,
First of all, many thanks to @ChiragGarg2512 for your very quick and effective replies.
Based on my testing, please try the following methods:
1.Create the simple table.
2.Create the new measure to filter month.
PreviousMonths =
VAR CurrentDate = TODAY()
VAR CurrentMonth = MONTH(CurrentDate)
VAR CurrentDay = DAY(CurrentDate)
VAR curyear = YEAR(CurrentDate)
RETURN
IF(
CurrentDay > 12,
CALCULATE(
SUMX('Table', 'Table'[Number]),
FILTER (
ALLEXCEPT('Table', 'Table'[Date]),
('Table'[Year] = curyear
&& 'Table'[Month] < CurrentMonth) || ('Table'[Year] = curyear - 1 && ('Table'[Month] > CurrentMonth + 5 && 'Table'[Month] <= 12))
)
),
CALCULATE(
SUMX('Table', 'Table'[Number]),
FILTER (
ALLEXCEPT('Table', 'Table'[Date]),
('Table'[Year] = curyear
&& 'Table'[Month] < CurrentMonth - 1) || ('Table'[Year] = curyear - 1 && ('Table'[Month] > CurrentMonth + 4 && 'Table'[Month] <= 12))
)
))
3.Drag the measure into the table visual and column chart. The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The error might be because of Calculatetable, try Calculate instead.