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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
tadeom0
Frequent Visitor

IF statement with decimal and text filters and another table with date filter

Hello DAX experts,

 

I want to generate a table or column that will filter the data by using text and decimal value. Also I want to filter using Calendar date.
The logic is IF the value is <0 and the text is "Deficit" and the Month is March then included.
If the value is >0 and the text is Deficit and the Month is March then excluded.

 

Let me know if you encountered this situation befor

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @tadeom0  - You can achieve this in Power BI by creating a calculated column or a measure to filter your data based on the conditions you specified

 

Filter_Status =
VAR MonthName = FORMAT('YourTable'[Date], "MMMM") -- Extracts the month name
RETURN
IF(
'YourTable'[TextColumn] = "Deficit" && MonthName = "March",
IF('YourTable'[Value] < 0, "Include", "Exclude"),
BLANK() -- Keeps other rows as blank
)

 

Add a page-level or visual-level filter where Filter_Status = "Include".

 

Hope this works. please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks for the reply from rajendraongole1.

 

Hi @tadeom0 ,

 

You can dynamically select months by creating a calculated table and using the slicer. The steps are as follows, and you can adjust them to suit your needs as well:

vlinhuizhmsft_0-1739941900465.png

 

1. Create a calculated table:

 

Month = ADDCOLUMNS(VALUES('Table'[Date]),"Month",MONTH('Table'[Date]))

 

vlinhuizhmsft_1-1739941918683.png

 

2. Create a measure:

 

Measure = 
VAR _month = MONTH(MAX('Table'[Date]))
VAR _table = DISTINCT('Month'[Month])
VAR _select = CONCATENATEX(_table, 'Month'[Month], ",")
RETURN
IF(
    CONTAINSSTRING(_select, _month) && MAX('Table'[Text]) = "Deficit",
    IF(MAX('Table'[Value]) < 0, "included", "excluded")
)

 

3. Create a slicer using the month field of the calculated table. The result is shown in the figure:

vlinhuizhmsft_2-1739942342119.png

Best Regards,
Zhu

 

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

rajendraongole1
Super User
Super User

Hi @tadeom0  - You can achieve this in Power BI by creating a calculated column or a measure to filter your data based on the conditions you specified

 

Filter_Status =
VAR MonthName = FORMAT('YourTable'[Date], "MMMM") -- Extracts the month name
RETURN
IF(
'YourTable'[TextColumn] = "Deficit" && MonthName = "March",
IF('YourTable'[Value] < 0, "Include", "Exclude"),
BLANK() -- Keeps other rows as blank
)

 

Add a page-level or visual-level filter where Filter_Status = "Include".

 

Hope this works. please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Is there a way that the month will be dynamic? or can i add more months and year to the selection?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors