This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Previous_year_sales = if(ISBLANK(SAMEPERIODLASTYEAR('Date'[Date])),
"No Sales",
CALCULATE([TotalSales],
SAMEPERIODLASTYEAR('Date'[Date]))
)
Solved! Go to Solution.
Hi @abbytank ,
Actually, the function ISBLANK is to check whether a value is blank. But it will return a table when you apply the function SAMEPERIODLASTYEAR. You can find the details in the following links.
Best Regards
Hi @abbytank ,
You can update the formula of measure [Previous_year_sales] as below, please notice that the data type of returned result will be Text type instead of Number type. If you still want to keep the data type as Number type, you can change "No Sales" to 0.
Previous_year_sales =
VAR _pysales =
CALCULATE ( [TotalSales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
RETURN
IF ( ISBLANK ( _pysales ), "No Sales", _pysales )
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. 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
Thank you very much @Anonymous for your supportive response.
I see your solutions is 100% working and providing the very desired result, but concern is:
This is working:
VAR _pysales =
CALCULATE ( [TotalSales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
return _pysalesAnd also, the following is working:
ISBLANK(SAMEPERIODLASTYEAR('Date'[Date]))
And even the first the part of the code is working, because when the previous years sales is empty (no sales on previous year) the result is working and showing "No Sales" result:
Previous_year_sales = if(ISBLANK(SAMEPERIODLASTYEAR('Date'[Date])),
"No Sales",
But the problem is, when the calculate function or even sumx function put on the IF functions as (if function's) return values (return values on true or false) according to the following:
Previous_year_sales = if(ISBLANK(SAMEPERIODLASTYEAR('Date'[Date])),
"No Sales",
CALCULATE([TotalSales],
SAMEPERIODLASTYEAR('Date'[Date]))
)
So, why calculate is not working in IF function's argument, that is my concern?
Thank you very much.
Hi @abbytank ,
Actually, the function ISBLANK is to check whether a value is blank. But it will return a table when you apply the function SAMEPERIODLASTYEAR. You can find the details in the following links.
Best Regards
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |