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

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.

Reply
KiravonEhren
Frequent Visitor

Month over month graph

Hello all,

I created a graph which shows the ROAS for this week and the previous week (x Axis = Day of week and y Axis= ROAS):

KiravonEhren_0-1654858704297.png


The measure for the ROAS of the previous week is calculated as follows : 

ROAS previous week =
D
ivide(
calculate(
sum('All data'[NetRevenue (Attributed, ToCnv)]),
'Date'[Week Number]=SELECTEDVALUE('Date'[Week Number])-1,
'Date'[Weekday number]=SELECTEDVALUE('Date'[Weekday number]),
'All data'[Costs (Total, Commission, ToCnv)]<>0),
calculate(
SUM('All data'[Costs (Total, Commission, ToCnv)]),
'Date'[Week Number]=SELECTEDVALUE('Date'[Week Number])-1,
'Date'[Weekday number]=SELECTEDVALUE('Date'[Weekday number]),
'All data'[Costs (Total, Commission, ToCnv)]<>0)
)

Now I wanted to do the same graph but instead of a week over week comparison with a month over month comparison: 
I tried to use the following formula to get the ROAS of the  previous month on a daily bases:
 
ROAS per Day previous Month =
divide(
calculate(sum('All data'[NetRevenue (Attributed, ToCnv)]),
'Date'[Month Number]=SELECTEDVALUE('Date'[Month Number])-1,
'Date'[Day Number]=SELECTEDVALUE('Date'[Day Number]),
'All data'[Costs (Total, Commission, ToCnv)]<>0),
calculate(SUM('All data'[Costs (Total, Commission, ToCnv)]),
'Date'[Month Number]=SELECTEDVALUE('Date'[Month Number])-1,
'Date'[Day Number]=SELECTEDVALUE('Date'[Day Number]),
'All data'[Costs (Total, Commission, ToCnv)]<>0)
)
 
However, the formula for month does not work even though I just copied the formula from the week over week comparison and exchanged week number for month number and weekday for day number...
 
Does anyone have an idea why?

Thank you very much! 🙂 
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi  @KiravonEhren,Please try to update the formula of measure [ROAS per Day previous Month] as below and check if can return the correct result...

PS: The part with red font is update ones....

ROAS per Day previous Month =
DIVIDE (
    CALCULATE (
        SUM ( 'All data'[NetRevenue (Attributed, ToCnv)] ),
        PREVIOUSMONTH ( 'All data'[Date] ),
        'All data'[Costs (Total, Commission, ToCnv)] <> 0,
        ALL ( 'All data' )
    ),
    CALCULATE (
        SUM ( 'All data'[Costs (Total, Commission, ToCnv)] ),
        PREVIOUSMONTH ( 'All data'[Date] ),
        'All data'[Costs (Total, Commission, ToCnv)] <> 0,
        ALL ( 'All data' )
    )
)

How to create Dax logic for this Month and Previous Month

Values of previous month


= CALCULATE(SUM(Table[Auftragsbestand]); VALUES(Table[PG]);DATEADD(Table[Datum];-1;MONTH))

Message error

If the above one can't help you get the desired result, please provide some sample data in your tables'All data'  and'Date'(exclude sensitive data) with Text format and yourexpected result with backend logic, screenshot of your visuals and special examples. By the way, is there any relationship created between the table 'All data'  and 'Date'? It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi  @KiravonEhren,Please try to update the formula of measure [ROAS per Day previous Month] as below and check if can return the correct result...

PS: The part with red font is update ones....

ROAS per Day previous Month =
DIVIDE (
    CALCULATE (
        SUM ( 'All data'[NetRevenue (Attributed, ToCnv)] ),
        PREVIOUSMONTH ( 'All data'[Date] ),
        'All data'[Costs (Total, Commission, ToCnv)] <> 0,
        ALL ( 'All data' )
    ),
    CALCULATE (
        SUM ( 'All data'[Costs (Total, Commission, ToCnv)] ),
        PREVIOUSMONTH ( 'All data'[Date] ),
        'All data'[Costs (Total, Commission, ToCnv)] <> 0,
        ALL ( 'All data' )
    )
)

How to create Dax logic for this Month and Previous Month

Values of previous month


= CALCULATE(SUM(Table[Auftragsbestand]); VALUES(Table[PG]);DATEADD(Table[Datum];-1;MONTH))

Message error

If the above one can't help you get the desired result, please provide some sample data in your tables'All data'  and'Date'(exclude sensitive data) with Text format and yourexpected result with backend logic, screenshot of your visuals and special examples. By the way, is there any relationship created between the table 'All data'  and 'Date'? It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Hello Ying, 

Thank you for your reply. This solution worked! 🙂 
Could you explain to me where my thinking was wrong and why my formula did not work? 
 Thank you so much, your help is highly appreciated!

Kira

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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