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
deb_power123
Helper V
Helper V

Convert Billion to Million in calculated table and add suffix M for the converted value

Hi All,

 

Below is an input table with AuditDate, Score ,school name and Percentage students.

 

AuditDateScoreSchoolNamePercentageStudents
15.08.2021-2A20%
15.08.2021-1B30%
16.08.20213C22%
16.08.20210D45%
16.08.2021-1A65%
17.08.2021-1B17%
17.08.2021-1C29%
18.08.20213A78%
18.08.20210C87%
19.08.2021-1C22%
19.08.20213D45%
19.08.20210E65%
20.08.2021-1B17%
21.08.20212D29%
22.08.20211E22%
22.08.2021-1A45%
1.09.20210E65%
1.09.2021-1B17%
2.09.20212D29%
3.09.20211E22%
3.09.2021-1A45%
4.09.20211C65%
5.09.20211C17%
5.09.20213A29%

 

I have the below calculated table to show current month, catefgory and Paramscore columns  as shown in below output. paramscore is the Average aggregate of the score and percentage students column in the input source table above.

 

We have created two categories to store these values in a column paramscore for respective month,year.

Calculated table :

NewTable = 
GENERATE (
    SUMMARIZE (
        SELECTCOLUMNS (
            'Table',
            "CurrentMonth", FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" )
        ),
        [CurrentMonth]
    ),
    ADDCOLUMNS (
        DATATABLE (
            "Category", STRING,
            {
                { "AverageScore" },
                { "AveragePercentage" }
            }
        ),
        "ParamScore",
            VAR _m = [CurrentMonth]
            RETURN
                IF (
                    [Category] = "AverageScore",
                    FORMAT (
                        CALCULATE (
                            AVERAGE ( 'Table'[Score] ),
                            FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) = _m
                        ),
                        ""
                    ),
                    FORMAT (
                        CALCULATE (
                            AVERAGE ( 'Table'[PercentageStudents] ),
                            FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) = _m
                        ),
                        "0%"
                    )
                )
    )
)

Expected Output:

Here the score is in unit of  Billion but I want to convert and show the value in Million and put M as a suffix. In ParamScore column, I want to display 0.1875  and 0.75  to 187.5 M and 750 M respectively.

 

Is it possible and if so please suggest the changes in the above formula.

 

Present Output:

deb_power123_0-1643112864515.png

Kind regards

Sameer

1 ACCEPTED SOLUTION

Hi @deb_power123 

 

Calculated Column = IF ( NewTable[Category] = "AverageScore" , NewTable[ParamScore] * 100 & "M" , IF ( NewTable[Category] = "AveragePercentage" , NewTable[ParamScore] & "%", NewTable[ParamScore] ) )

 

Hope this works for you 🙂

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

View solution in original post

6 REPLIES 6
TheoC
Super User
Super User

Hi @deb_power123 

 

Can you add a Calculated Column to NewTable? Maybe something like "Calculated Column = IF ( NewTable[Category] = "AverageScore" , NewTable[ParamScore] * 100 & "M" , NewTable[ParamScore] )"

 

Apologies for syntax errors. On phone.

 

All the best.

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Hi @TheoC 

 

Thankyou for the approach, I will like to extend your suggestions a little further. I also want to add a percentage sign using your approach for AveragePercentage column. Assuming we dont have % sign as shown in my screenshot. How can I append it in the below code you suggested?

 

I tried to modify your code a further as below in blue font but it threw error.

 

Could you suggest , please. How can we loop both these changes in your provided calculated column approach.

 

Calculated Column = IF ( NewTable[Category] = "AverageScore" , NewTable[ParamScore] * 100 & "M" , NewTable[ParamScore]

IF ( NewTable[Category] = "AveragePercentage" , NewTable[ParamScore]  & "%" , NewTable[ParamScore]

)

Hi @deb_power123 

 

Calculated Column = IF ( NewTable[Category] = "AverageScore" , NewTable[ParamScore] * 100 & "M" , IF ( NewTable[Category] = "AveragePercentage" , NewTable[ParamScore] & "%", NewTable[ParamScore] ) )

 

Hope this works for you 🙂

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

I accepted the solution , its working but I have a last query for which I will PM you  as per your suggestions

Hi @TheoC

It certainly worked.I have a last question.Sorry for asking a lot of questions. I also want to create a calculated column or measure which has the difference of the paramscore of the latest month and paramscore of the previous month. Assuming August 2021 is our latest month and September 2021 is the previous month because in real case scenario there are 8 to 9 months so it should find the latest and then substract the value of the previous month from that. 

 

Could you please suggest a calculated column or measure which can find the difference ?

 

Average_Score_diff  = 0.1875 -0.750 = -0.5625

Average_Percentage_difference = 40% - 36% = 4%

 

Could you please suggest?I think this will be my last question in this topic.

 

Kind regards

Sameer

Hi @deb_power123 

 

Can I ask that you mark the answer as the solution so that the Community has access to the answer when they search and if you send me a PM, I can assist with the additional queries?

 

Thanks so much for understanding and I appreciate you letting me know it worked!

 

I'll respond via PM when I get in front on computer.  On phone atm.

 

Thanks heaps!

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

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.