Forum Discussion

Puja's avatar
Puja
Icon for Helper III rankHelper III
3 years ago
Solved

Help with SUMMARIZE

Hi All,

I am trying to get correct totals but I am not able to include blank RegionCode data. Can someone help me .Thanks

 

Measure=
VAR a =
    SUMX(
        SUMMARIZE(DimRegion, DimRegion[RegionCode], "AA", [Constant USD]) ,[AA])
       
RETURN  a
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Puja ,

     

    To include blank RegionCode data in your Power BI Desktop table visual, you can modify your DAX measure to include a condition that checks for blank values. Here's an example of how you can modify your measure:

    Measure = 
    VAR a =
        SUMX(
            SUMMARIZE(DimRegion, DimRegion[RegionCode], "AA", [Constant USD]), [AA]
        )
    VAR b =
        CALCULATE(
            [AA],
            FILTER(DimRegion, ISBLANK(DimRegion[RegionCode]))
        )
    RETURN 
        IF(
            ISBLANK(a),
            b,
            IF(
                ISBLANK(b),
                a,
                a + b
            )
        )

     

    In this modified measure, we first calculate the sum of the non-blank values using the same formula as before. We then calculate the sum of the blank values using the CALCULATE and FILTER functions. Finally, we add the two sums together to get the total.


    Note that this assumes that the RegionCode column is a text column. If it is a numeric column, you can modify the ISBLANK function to use BLANK instead.

     

     

    Best Regards,

    Stephen Tao

     

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

     

4 Replies

  • ppm1's avatar
    ppm1
    Icon for Solution Sage rankSolution Sage

    Try summarizing your fact table instead. You can also simplify the expression as follows.

     

    SUMX(
            SUMMARIZE(FactTableDimRegion[RegionCode])[Constant USD])
     
    Pat
    • Puja's avatar
      Puja
      Icon for Helper III rankHelper III

      hi ppm1 

      Thanks for the reply.

      Your solution is not working.

       

      Thank you

      • ppm1's avatar
        ppm1
        Icon for Solution Sage rankSolution Sage

        Can you share more about your model (show tables/relationships from diagram view), and share the [Constant USD] measure expression?

         

        Pat

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Puja ,

     

    To include blank RegionCode data in your Power BI Desktop table visual, you can modify your DAX measure to include a condition that checks for blank values. Here's an example of how you can modify your measure:

    Measure = 
    VAR a =
        SUMX(
            SUMMARIZE(DimRegion, DimRegion[RegionCode], "AA", [Constant USD]), [AA]
        )
    VAR b =
        CALCULATE(
            [AA],
            FILTER(DimRegion, ISBLANK(DimRegion[RegionCode]))
        )
    RETURN 
        IF(
            ISBLANK(a),
            b,
            IF(
                ISBLANK(b),
                a,
                a + b
            )
        )

     

    In this modified measure, we first calculate the sum of the non-blank values using the same formula as before. We then calculate the sum of the blank values using the CALCULATE and FILTER functions. Finally, we add the two sums together to get the total.


    Note that this assumes that the RegionCode column is a text column. If it is a numeric column, you can modify the ISBLANK function to use BLANK instead.

     

     

    Best Regards,

    Stephen Tao

     

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