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
Suneer
Frequent Visitor

Dax query - How to Filter with If Condition in Pagination Report

Our company maintaning 2 databases Historical & Current Production Database. I want to filter the details of Inventory by the follwing conditions to use in pagination report


if Historical data then month = 4 (For Example) and If it is production data then month <=4

 

Something like this, please help

FILTER(VALUES('StockAnalyzerUnion'[Month]),'StockAnalyzerUnion'[Month] --- If ('StockAnalyzerUnion'[Data] ="Historical",4,<=4)))

4 REPLIES 4
Suneer
Frequent Visitor

Hi @tamerj1 

 

Thank you for your response, i applied the way you explained, it is working for currenct data but not filtering for the month of 4 for Historical Data but summarizing with all month (From 1 to 4) .

MonthHistoricalCurrent
11000500
21200600
31400300
41500400
Total51001800

 

as per the above example,  historical data should bring 1500 but it showing 5100 (Total) , current data should show only the summary 1800 which is correct

 

Please see the Dax query which i applied mentioned below

 

EVALUATE SUMMARIZECOLUMNS('StockAnalyzerUnion'[Branch],
'StockAnalyzerUnion'[Company],
'StockAnalyzerUnion'[Data],
'StockAnalyzerUnion'[Division Name],
'StockAnalyzerUnion'[Group Name],
'StockAnalyzerUnion'[Location],
'StockAnalyzerUnion'[Month],
'StockAnalyzerUnion'[Year],
'StockAnalyzerUnion'[Qty],
'StockAnalyzerUnion'[Value],
FILTER (VALUES ( 'StockAnalyzerUnion'[Month]),
IF ( CALCULATE ( SELECTEDVALUE ( 'StockAnalyzerUnion'[Data] ) ) = "Historical",
'StockAnalyzerUnion'[Month] = 4,
'StockAnalyzerUnion'[Month] <= 4)))

 

but this problem has been resolved by using the calculated field feature in report builder. 

Thank you once again 

@Suneer 

Calculated tables cannot interact with the filter context hence are not dynamic. What exactly are you trying to accomplish?

Recently our company had implemented new ERP.  In the new ERP, if we want to run the inventory upto April we should start from the begining where the old ERP is running by month wise only (no need to run from the begining). Both data are available as power bi dataset.  But the problem is if i want to compare both inventory for the month of April,  The new ERP should take the data from the begining where old ERP by that particular month

 

As i mentioned this problem has been resolved by using calculation fiield, i made 2 calulation fields both Old and New . 

tamerj1
Super User
Super User

Hi @Suneer 

Please try

=
FILTER (
VALUES ( 'StockAnalyzerUnion'[Month] ),
IF (
CALCULATE ( SELECTEDVALUE ( 'StockAnalyzerUnion'[Data] ) ) = "Historical",
'StockAnalyzerUnion'[Month] = 4,
'StockAnalyzerUnion'[Month] <= 4
)
)

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.