Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi All,
I have sempy working in Notebook and can pass filters as explained in Microsoft documentation.
Solved! Go to Solution.
Hi @anandfarmers ,
Apologies for the delay in reply from our side.
fabric.evaluate_measure has the limitation of the filter that only suppors the 'in' operator.
If you are looking towards range operation then i recommed to use fabric.evaluate_dax .
For eg:
import sempy.fabric as fabric
df_dax = fabric.evaluate_dax(
"Customer Profitability Sample",
"""
EVALUATE SUMMARIZECOLUMNS(
'State'[Region],
'Calendar'[Year],
'Calendar'[Month],
'State'[State],
FILTER('Calendar', 'Calendar'[Year] >= 2009 && 'Calendar'[Year] <= 2011),
)
""")
df_dax
Inorder to get some idea please refer below link,
Read data from semantic models and write data that semantic models can consume - Microsoft Fabric | ...
FILTER function (DAX) - DAX | Microsoft Learn
Hope this is helpful. Please let me know incase of further queries.
Hi @anandfarmers ,
Thanks for using Fabric Community.
Can you please check if below code works for you, it can get data filter by month and year.
import sempy.fabric as fabric
filters = {
"State[Region]": ["East", "Central"],
"State[State]": ["FLORIDA", "NEW YORK"],
"Calendar[Month]": ["Aug"],
"Calendar[Year]": [2013]
}
df_measure = fabric.evaluate_measure(
"Customer Profitability Sample",
"Total Revenue",
["Customer[State]", "Calendar[Date]", "Calendar[Month]", "Calendar[Year]"],
filters=filters)
df_measure
Hope this is helpful. Please let me know incase of further queries.
Hi @Anonymous ,
Thanks for the reply.
I understand we can give month name.
But as I mentioned, if the date range starts part of a month and ends part of the same month or another month then we have to list each date. e.g. 2nd of Jan 2023 to 5th of March 2023.
I am trying to understand how to give such date ranges.
Hi @anandfarmers ,
Apologies for the delay in reply from our side.
fabric.evaluate_measure has the limitation of the filter that only suppors the 'in' operator.
If you are looking towards range operation then i recommed to use fabric.evaluate_dax .
For eg:
import sempy.fabric as fabric
df_dax = fabric.evaluate_dax(
"Customer Profitability Sample",
"""
EVALUATE SUMMARIZECOLUMNS(
'State'[Region],
'Calendar'[Year],
'Calendar'[Month],
'State'[State],
FILTER('Calendar', 'Calendar'[Year] >= 2009 && 'Calendar'[Year] <= 2011),
)
""")
df_dax
Inorder to get some idea please refer below link,
Read data from semantic models and write data that semantic models can consume - Microsoft Fabric | ...
FILTER function (DAX) - DAX | Microsoft Learn
Hope this is helpful. Please let me know incase of further queries.
Thank you for the reply.
It calrifies different use cases of the functions.
Hi @anandfarmers ,
Glad to know that your query got resolved. Please continue using Fabric Community for your further queries.
Check out the September 2024 Fabric update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.