Forum Discussion

siva_yellanuri's avatar
siva_yellanuri
New Member
2 years ago

Unable to get accurate result when comparing current data with previous data based on the filter con

Hello Team,

when I compare the live table data with historical table data it is working  fine. If I use filter condition then figures are slightly changing and trends are not working . Request you  please provide solution for this 

 

I used dax formula like this 

 

Previous week = snapshot table and this week = Opportunity table 

 

Snapshots_Unweigted Orderentry_Budget% = 

IF(RIGHT(SELECTEDVALUE(Snapshots[Fiscal Period]),4)&"-"&LEFT(SELECTEDVALUE(Snapshots[Fiscal Period]),2) < [Current_Quater], DIVIDE([ActualsWon_IND],[Budget_IN],0), IF(([ActualsWon_IND] < [Budget_IN]), [TotalOE]/([Budget_IN]-[ActualsWon_IND]), DIVIDE(([TotalOE]+[ActualsWon_IND]),[Budget_IN],0)))
 
 

Opportunities_Unweigted Orderentry_Budget% = 

IF(RIGHT(SELECTEDVALUE(Opportunities[Fiscal Period]),4)&"-"&LEFT(SELECTEDVALUE(Opportunities[Fiscal Period]),2) < ([Current_Quater]), ([c_ActualsWon_IND]/[c_Budget_IND]), IF([c_ActualsWon_IND] < [c_Budget_IND], DIVIDE([c_TotalUOE],([c_Budget_IND]-[c_ActualsWon_IND]),0),DIVIDE(([c_TotalUOE]+[c_ActualsWon_IND]),[c_Budget_IND],0)))
 
 
Trends = [Opportunities_Unweigted Orderentry_Budget%]-[Snapshots_Unweigted Orderentry_Budget%]
 
These formulas are working fine without filter conditions . If i use Slicer Region wise, Ex: North America, Northern Europe, Southeren Europe and select any one of that then all 3 formulas are not giving the accurate result.
 
Snapshots: not accurate
 

 

Opportunities :  Not accurate

 

 

 Trends : Coming wrong data.
 

 

 
 
 
Kind Regards,
Siva

 

 

 

 

 

 

 

 

 

 

4 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion

    siva_yellanuri  Your DAX looks like a rather complex text manipulation - what is your data source? Can you do some of the RIGHT() and LEFT() functions in Power Query instead of DAX? What does your data model look like? Having your data model set up as a proper star schema will help. Can you share your relationships and raw data and some more info? 

    Here's some blogs I wrote on star schema that may help too: Excel with Allison: Search results for complicated

  • Hi Allison,

    Thanks for your reply. Actually data is coming from the Business application so that is live data i wont get Report  view option to go to power query to update the changes instead of DAX. There is no relationships between snapshots, Opportunities tables. By using the Treatas function i make the relationship between these tables. I cann't send the Raw data. Request you please assist me why the figures in the tables are not accurate if i filter the data in the slicer.

    • AllisonKennedy's avatar
      AllisonKennedy
      Icon for Community Champion rankCommunity Champion

       How are you getting on with solving this problem? 

       

      We need a bit more detail from you still around how your tables are related, TREATAS function is powerful, but as   mentioned, you need to be clear about which filters you're using and ensure they're related to the tables in your report or the measure that uses the TREATAS. 

      Can you share your treatas measures?

       

      Also, careful with your < and > as you're using these in a text field, so they may not behave how you expect.

       

      I have used Daxformatter.com to format one of your measures, makes it a bit easier to read:

       

      Opportunities_Unweigted Orderentry_Budget% =
      IF (
          RIGHT (
              SELECTEDVALUE ( Opportunities[Fiscal Period] ),
              4
          ) & "-"
              & LEFT (
                  SELECTEDVALUE ( Opportunities[Fiscal Period] ),
                  2
              ) < ( [Current_Quater] ),
          ( [c_ActualsWon_IND] / [c_Budget_IND] ),
          IF (
              [c_ActualsWon_IND] < [c_Budget_IND],
              DIVIDE (
                  [c_TotalUOE],
                  ( [c_Budget_IND] - [c_ActualsWon_IND] ),
                  0
              ),
              DIVIDE (
                  ( [c_TotalUOE] + [c_ActualsWon_IND] ),
                  [c_Budget_IND],
                  0
              )
          )
      )

       

       

      Anonymous

      siva_yellanuri

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AllisonKennedy ,

    Thanks for the quick response.

    Hi siva_yellanuri ,

    I have some information to add.

    Ensure that your slicers are correctly configured to interact with both your and tables. If your slicers are not properly connected to these tables, it could lead to inaccurate filtering and, consequently, incorrect results. 

    More details : https://learn.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-slicers.

    The behavior you're experiencing could be due to how the filter context is applied when you select a region from the slicer. It's important to understand that slicers change the filter context, and this can affect your DAX calculations. More details : https://learn.microsoft.com/en-us/power-bi/guidance/dax-filter-context.

     

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

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