cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## i want to calculate previous month Dax measure for Fiscal month format

I am getting the result but only till the 2022/12 after that the value is showing for the next month is blank I need the value 15736 to display over there. Can you please help ?

2 ACCEPTED SOLUTIONS
Community Support

You can try the following methods.
Column:

``Fiscal Month2 = LEFT([Fiscal Month],4)*100+RIGHT([Fiscal Month],2)``

Measure:

``````Pre month SO =
Var _Prevmonth=MAXX(FILTER(ALL('Table'),[Fiscal Month2]<SELECTEDVALUE('Table'[Fiscal Month2])),[Fiscal Month2])
Return
CALCULATE([No of distinct Sales order],FILTER(ALL('Table'),[Fiscal Month2]=_Prevmonth))``````

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Frequent Visitor

Thank you 🙂

10 REPLIES 10
Post Partisan

Sua tabela de data (dCalendar) precisa deste campo:

``"Ano Mes Num", YEAR ( [Date] ) * 12 + MONTH ( [Date] ) - 1``

Em seguida, fazer esta medida:

``````Total =
CALCULATE (
[Qtde],
WINDOW (
-1,
REL,
-1,
REL,
ALLSELECTED ( dCalendar[MesAno], dCalendar[Ano Mes Num] )
)``````

Frequent Visitor

Thank you 🙂

Super User

Hi,

Create a Calendar Table with calculated column formulas of FY, Month name and Month number.  Sort the Month name by the Month number.  Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table.  To your visual, drag FY and Month name from the Calendar Table.  Write this measure

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Helper III

Hi @SupriyaVarun, if you can provide a santized dataset similar to your actual data, it will easy to create a solution and share it with you. You can either give your sample data as an Excel file or PBIX. (Just in case it is okay with you. Else please ignore).

Super User

@SupriyaVarun

You can try converting fiscal month by changing it to date format or create date column as below. Then use previous month function.

Prev_SO = CALCULATE(sum('SOW'[No of disctinct SO#]),PREVIOUSMONTH('SOW'[Date]))

Let me know if this helps!
If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate your kudos!!

Frequent Visitor

But I have used the above measure, it did not work as I needed the values were showing incorrect as per calendar table.

I need the measure using Fiscal month not the calendar month

Super User

Use the below logic, Basically when month is 1, it bexomes zero due to  -1 and not 12. Also try it with and without the highlighted part(This is to pull out 2022 instead of 2023). Depending on your calendar table sturcture either year - 1 or just year will work.

Prev_ =
VAR CM =
VALUE ( RIGHT ( MAX ( 'SM Dim Calendar'[Fiscal Month] ), 2 ) )
VAR jan =
CALCULATE (
SUM ( SOW[No of disctinct SO#] ),
VALUE ( RIGHT ( 'SM Dim Calendar'[Fiscal Month], 2 ) )
= VALUE (
RIGHT ( FORMAT ( MAX ( 'SM Dim Calendar'[Fiscal Month] ), "YYYY/MM" ), 2 )
) + 11,
'SM Dim Calendar'[Fiscal Year]
= FORMAT ( MAX ( 'SM Dim Calendar'[Date] ), "YYYY" ) - 1
)
VAR Others =
CALCULATE (
SUM ( SOW[No of disctinct SO#] ),
VALUE ( RIGHT ( 'SM Dim Calendar'[Fiscal Month], 2 ) )
= VALUE (
RIGHT ( FORMAT ( MAX ( 'SM Dim Calendar'[Fiscal Month] ), "YYYY/MM" ), 2 )
) - 1,
'SM Dim Calendar'[Fiscal Year]
= FORMAT ( MAX ( 'SM Dim Calendar'[Date] ), "YYYY" )
)
VAR FInal =
IF ( CM = 1, jan, Others )
RETURN
FInal

Let me know if this helps!
If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate your kudos!!

Frequent Visitor

The columns i have used Fiscal Month from calendar table,

No of distinct Sales order = DISTINCTCOUNT('SM Fact [Sales Order Number])
Now I need Previous fiscal month sales order only the 2023/01 value is showing blank.

Community Support

You can try the following methods.
Column:

``Fiscal Month2 = LEFT([Fiscal Month],4)*100+RIGHT([Fiscal Month],2)``

Measure:

``````Pre month SO =
Var _Prevmonth=MAXX(FILTER(ALL('Table'),[Fiscal Month2]<SELECTEDVALUE('Table'[Fiscal Month2])),[Fiscal Month2])
Return
CALCULATE([No of distinct Sales order],FILTER(ALL('Table'),[Fiscal Month2]=_Prevmonth))``````

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

Hello @SupriyaVarun

Can you try to add Allselected(table,table[fiscal month]) in you filters, If this doesn't make a change please share a sample data with all the columns used in the table visual.

Let me know if this helped.

If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate your kudos!!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors