Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
SupriyaVarun
Frequent Visitor

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

SupriyaVarun_0-1685726921508.png

 

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

Hi, @SupriyaVarun 

 

You can try the following methods.
Column:

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

vzhangti_0-1686550778739.png

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))

vzhangti_1-1686551063880.png

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.

 

View solution in original post

10 REPLIES 10
VilmarSch
Post Patron
Post Patron

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] )
    )

 

Resultado:

BricioJ_0-1685734290418.png

Thank you 🙂 

Ashish_Mathur
Super User
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

Measure = calculate([your measure],previousmonth(Calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
RajaCSN
Helper III
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).

NaveenGandhi
Super User
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.

NaveenGandhi_0-1685731216618.png

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!!

Thanks for your help  🙂


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 

 

@SupriyaVarun 

 

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!!

SupriyaVarun
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.

SupriyaVarun_1-1685730449102.png

 

 




Hi, @SupriyaVarun 

 

You can try the following methods.
Column:

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

vzhangti_0-1686550778739.png

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))

vzhangti_1-1686551063880.png

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.

 

NaveenGandhi
Super User
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!!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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