Forum Discussion

sdhn's avatar
sdhn
Icon for Responsive Resident rankResponsive Resident
4 years ago
Solved

DAX Calc.

Hi All,

 

I have  a Source SS as below.

 

 

I want to remove last row total and wants to calculate values thru Power Bi.

 

There are  formulas in the total of Column E  & I as:

 

Total : Column" E" 43:

=IF(D43<=0,"N/A",(C43/D43))

 

Total: Column "1 "43:

=IF(H43>0,(H43/D43),"N/A")

 

I need help here.

Do I need write  measure? if yes, how to start DAX for if etc.

 

help will be appreciated. Thanks 
  • Hi, 

    According to your description, I can roughly understand your requirement, I think you can try to achieve this by creating 3 measures for the columns E, H, and I:

    Column E =
    
    var _D43=SUMX(ALL('Table'),'Table'[D])
    
    var _C43=SUMX(ALL('Table'),'Table'[C])
    
    return
    
    IF(_D43<=0,"N/A",DIVIDE(_C43,_D43))
    Column H =
    
    var _F43=SUMX(ALL('Table'),'Table'[F])
    
    var _G43=SUMX(ALL('Table'),'Table'[G])
    
    return
    
    _F43+_G43
    Column I =
    
    var _H43=SUMX(ALL('Table'),'Table'[D])
    
    var _D43=SUMX(ALL('Table'),'Table'[C])
    
    return
    
    IF(_H43>0,"N/A",DIVIDE(_H43,_D43))

    And you can create a table chart to place the measures to get what you want, like this:

     

    You can download my test pbix file below

     

    If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

    How to Get Your Question Answered Quickly 

    Thank you very much!

     

    Best Regards,

    Community Support Team _Robert Qin

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

3 Replies

  • v-robertq-msft's avatar
    v-robertq-msft
    Icon for Community Support rankCommunity Support

    Hi, 

    According to your description, I can roughly understand your requirement, I think you can try to achieve this by creating 3 measures for the columns E, H, and I:

    Column E =
    
    var _D43=SUMX(ALL('Table'),'Table'[D])
    
    var _C43=SUMX(ALL('Table'),'Table'[C])
    
    return
    
    IF(_D43<=0,"N/A",DIVIDE(_C43,_D43))
    Column H =
    
    var _F43=SUMX(ALL('Table'),'Table'[F])
    
    var _G43=SUMX(ALL('Table'),'Table'[G])
    
    return
    
    _F43+_G43
    Column I =
    
    var _H43=SUMX(ALL('Table'),'Table'[D])
    
    var _D43=SUMX(ALL('Table'),'Table'[C])
    
    return
    
    IF(_H43>0,"N/A",DIVIDE(_H43,_D43))

    And you can create a table chart to place the measures to get what you want, like this:

     

    You can download my test pbix file below

     

    If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

    How to Get Your Question Answered Quickly 

    Thank you very much!

     

    Best Regards,

    Community Support Team _Robert Qin

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

  • Hi sdhn 

     

    Can you post sample data as text and expected output?
    Not enough information to go on;

    please see this post regarding How to Get Your Question Answered Quickly:
    https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.
    4. Relation between your tables

    Appreciate your Kudos!!
    LinkedIn:www.linkedin.com/in/vahid-dm/

  • sdhn's avatar
    sdhn
    Icon for Responsive Resident rankResponsive Resident

    Column 😧  =(B2+C2) to  Row 43:  =SUM(B43:C43)

    Column E :  =IF(D2<=0,"N/A",(C2/D2))  to Row 43: =IF(D43<=0,"N/A",(C43/D43))

    Column H :  =IF(D2>0,SUM(F2:G2),0)  to Row 43: =SUM(F43:G43)

    Column I : =IF(H2>0,(H2/D2),"N/A") to Row 43: =IF(H43>0,(H43/D43),"N/A")

     

     

    ABCDEFGHIDate
     32296147.5%6.26133.91140.172.298APRIL 2021
     720720.0%0.9984.1685.151.183APRIL 2021
     6622328977.2%30.09287.41317.501.099APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     2029329531.5%29.77848.15877.922.976APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     81910,92411,74393.0%1,235.696,200.917,436.600.633APRIL 2021
     7101,8862,59672.7%269.702,420.282,689.981.036APRIL 2021
     12332244572.4%46.25592.31638.561.435APRIL 2021
     3,55911,01514,57475.6%1,515.9812,351.1713,867.150.951APRIL 2021
     831,1271,21093.1%127.32870.46997.780.825APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     5831,0401,62364.1%167.484,685.924,853.402.990APRIL 2021
     1,3041821,48612.2%148.001,246.171,394.170.938APRIL 2021
     6,93811,37418,31262.1%1,887.7716,658.1718,545.941.013APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     4,71724,93029,64784.1%3,104.2731,423.8334,528.101.165APRIL 2021
     2,45415,39017,84486.2%1,869.2518,757.6820,626.931.156APRIL 2021
     3,45529,40232,85789.5%3,449.1029,279.0332,728.130.996APRIL 2021
     1,77310,51712,29085.6%1,286.719,997.2011,283.910.918APRIL 2021
     1,7234,8426,56573.8%682.107,800.388,482.481.292APRIL 2021
     9191,4882,40761.8%248.045,154.515,402.552.245APRIL 2021
     7,21521,66728,88275.0%3,009.3138,899.1941,908.501.451APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     7191,0761,79559.9%184.701,018.911,203.610.671APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     10117627763.5%28.58301.85330.431.193APRIL 2021
     3,3073,6356,94252.4%711.918,714.719,426.621.358APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     1,7438882,63133.8%265.984,111.804,377.781.664APRIL 2021
     10 100.0%0.9960.9761.966.196APRIL 2021
     37414351727.7%52.051,619.561,671.613.233APRIL 2021
     000N/A0.000.000.00N/AAPRIL 2021
     10435381.1%5.5326.0631.590.596APRIL 2021
     8455384.9%5.5528.6234.170.645APRIL 2021
    Totals:43,019152,457195,47678.0% $       20,369.37 $   203,573.32 $   223,942.691.146