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
Anonymous
Not applicable

Need support on PBI DAX

Hi all

 

Need your support on POWERBI DAX.

I am converting Tableau to PowerBI. 

Below is the Tableau calculation and I am trying in PBI DAX. can anyone please help me out.

 

 

1) Scenario 1

IF (NOT ISNULL([Colomn1]) OR [Colomn1] <> 0)
AND ISNULL([Colomn2])
THEN 0 ELSE ([[Colomn2])
END

 

I have written below DAX calculation, but not sure.

 

IF((NOT(ISBLANK([Colomn1]) || [Colomn1 <> 0]))
&& ISBLANK([Colomn2]),0,[Colomn2])
 
please correct me, if i am wrong.
 
2) 1) Scenario 2
 
SUM(IFNULL([Colomn 1],0)) - SUM([Colomn 5])
 

I have written below DAX calculation, but not sure.

COlomn X = IF(ISBLANK([Colomn 1]),0,[Colomn 1])

 

SUM([Colomn X]- SUM(Colomn 5])

 

please correct me.

 

thanks in advance

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

Your dax formulas in both senarios are correct. In addtion, you don't need to add a new column [Column X] in senario 2, you can use dax like below:

Result =
SUMX ( FILTER ( Table, Table[Colomn 1] <> BLANK () ), [Column 1] )
    - SUM ( [Colomn 5] )

Community Support Team _ Jimmy Tao

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

View solution in original post

9 REPLIES 9
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

Your dax formulas in both senarios are correct. In addtion, you don't need to add a new column [Column X] in senario 2, you can use dax like below:

Result =
SUMX ( FILTER ( Table, Table[Colomn 1] <> BLANK () ), [Column 1] )
    - SUM ( [Colomn 5] )

Community Support Team _ Jimmy Tao

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

Anonymous
Not applicable

Hi @v-yuta-msft ,

 

Still my end results are incorrect, below is the final calculation to find whether it is increased or decreased based on senario 2 result. 

 

senario 2 Result = SUMX ( FILTER ( Table, Table[Colomn 1] <> BLANK () ), [Column 1] ) - SUM ( [Colomn 5]

 

Tableau Calculation

IF { FIXED [Project ID] : ([senario 2 result]) } > 0 THEN "Increased"
ELSEIF { FIXED [Project ID] : ([senario 2 result]) } < 0 THEN "Decreased"
ELSEIF { FIXED [Project ID] : ([senario 2 result)]) } = 0 THEN "No Change"
ELSE NULL
END

 

PBI DAX

Variance = CALCULATE( [senario 2 result)],ALLEXCEPT([Project ID]))
Increased or Decreased Variance = IF([Variance]>0,"increased",IF([Variance]<0,"Decreased",IF([Variance]=0,"No change",Blank())))

 

Final output should be as below in Table green and Table red is what i am getting in PBI

 

Issue.PNG

 

Thank you in advance.

 

Regards,

Murali

So looking at your measures and output, it should be working. 
Assuming you're outputting [Variance] below the category, your DAX looks to be right.  You're getting the right values, but Project B is showing up in the wrong category.  Is [Increased or Decreased Variance] a measure or calculated column?  What visualization are you using to create the incorrect table?

 

Is it possible for you to anonymize a data sample and share it? Or even a sample .pbix?  

Anonymous
Not applicable

@Cmcmahan  Thank you very much.

 

I have created calculated column for increased or decreased variance using senario 2 Result (in the sheet Below) and senario 2 Result is a calculated measure.

I have used Matrix visual to show case

Sorry i dont have access to send doc , so sending you dummy data in text format.

 

Project ID
senario 2 Result
Categorisation
KALLI331834939842XE1
KALLI331845365377EN1
KALLI333955331386EN1
KALLI333963116971EN1
KALLI33396791700EN1
KALLI33116378474XE1
KALLI33376853712XE1
KALLI33349149999XE1
KALLI33346133392IFN
KALLI33365333111XE1
KALLI33396633464EN1
KALLI33396431435EN1
KALLI33381531116IFN
KALLI33397737972EN1
KALLI33359810000IFN
KALLI3334968112XE1
KALLI3317916692XE1
KALLI3337366315XE1
KALLI3339615199EN1
KALLI3317473582IFN
KALLI3339763134EN1
KALLI3331141111EN1
KALLI333493-3750AC1
KALLI333181-13319XE1
KALLI333467-35355AC1
KALLI331771-31191AC1
KALLI333347-31465XE1
KALLI119717-88151AC1
KALLI333741-91887XE1
KALLI333656-135396XE1
KALLI331953-153874AC1
KALLI331851-165862AC1
KALLI331733-337887AC1
KALLI333941-337939AC1

 

Once again thank you very much for responding 

Thanks,

Murali

 

So, literally copy/pasting your data and measure, I was able to create this which seems to work as you intended:
snipa.PNG

 

So at this point I'm curious about your original tables.  How do you have 2 different values for Category A?  Are there multiple categories within the same ProjectID?  What data did you use to create those original tables since my numbers are much larger, but I also don't have the raw data to calculate [scenario 2] myself.

Anonymous
Not applicable

@Cmcmahan 

 

Can you please remove the below Project ID's ( values and categories should remain ) from the source.

 

KALLI333955
KALLI333653
KALLI333598
KALLI333656
KALLI333941

 

Because i will be using this visual as a filter, so that detail chart will pop me which are the projects are increased and decreased and their categories accordingly 

 

can you please share me the .pbix file.

 

Thanks,

Murali

Anonymous
Not applicable

@CmcmahanWow brilliant

 

This is what exactly i wanted but, i still getting incorrect values. 

I don't see you using the Project ID information, Project ID should be fixed and then you need to calculate the variance.

hope you have used similar below calculation to create variance.

 

Variance = CALCULATE( [senario 2 result)],ALLEXCEPT([Project ID]))
Increased or Decreased Variance = IF([Variance]>0,"increased",IF([Variance]<0,"Decreased",IF([Variance]=0,"No

change",Blank())))

 

Senario 2 is difference of two fields, pretty straight .

 

can you please share me .pbix file, so that i will help me to understand better.

 

There can be projects where they are decreased due to any reason and some projects would have performed well and those are in increased bucket. 

 

The project status could be multiple categories ( stages ) and those projects can be present in decreased bucket and increased bucket too

 

Numbers are dummy.

 

Thank you very much

 

Thanks,

Murali

I can't calculate scenario 2 result myself, since I don't have raw data real or fake. 

In the data you provided, each [Scenario 2 result] is already associated with a Project ID.  The difference between your [Scenario 2 result] and [Variance] is that [Variance] is [Scenario 2 result] where the Project ID is the same. Since all the project IDs are distinct, I just renamed [Scenario 2 result] to [Variance].  I could set up the exact same measure you have for [Variance] and this would still work identically.

I grouped them by category, since the table you showed doesn't have any ProjectID groupings.  The values in the matrix are the SUM of all values in that category. Removing the project IDs changes nothing, since those values are still in the category buckets. If you can provide sample raw data so I can start from square one, or a screenshot of your current visual and the associated fields, I can help further.  Also, if the example data had projects with multiple categories, that would be great too.

 

EDIT: Here's the matrix if I set up rows split by project:
snipa.PNG

Anonymous
Not applicable

Hi @Cmcmahan :

 

Thank you very much for your extended support and connecting with me offline.

Appreciate your dedication towards resolving the issue.

 

 

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.