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.
Hello everyone,
Basically need to get the unit information for a measure, I have been checking the "dataView " but havent seen any correspondent data.
Any help is welcome !
thanks for the support.
Solved! Go to Solution.
Hi @Anonymous,
I'm still not 100% clear on your objectives here. How are you providing the unit information to your dataView? Is this what the dimensions data role represents in your dataViewMapping or is it a custom format string against the measure supplied as the measures data role?
If you're setting a custom format string in the data model (e.g. "0.00 kg"), then it will come into the values array in the dataViewMapping as a raw value and its corresponding columns entry should have a format property that will contain the format string you've set up in the model.
You can then use valueFormatter from powerbi-visuals-utils-formattingutils to format the raw value using the format string from the object metadata. As there's no format property in for the measure metadata in your screenshot I'm guessing that isn't the case though.
Or, are you trying to introduce some logic into your visual to apply a denominator and add units to a measure based on a property?
What would be useful is if we could start with the following information:
If I can get some further detail or clarification hopefully I can provide a more targeted answer for you.
Regards,
Daniel
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Hi @dm-p ,
The issue was that we did not prepare the data, and by the light of the information you have given I have checked the properties for the measure and found the format as :
And by checking the metadata after setting the format, I could have seen it :
Thank you for all your help and enlighting to find the solution.
Fantastic to hear - glad you're sorted! 🙂
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Hi @Anonymous,
I'm still not 100% clear on your objectives here. How are you providing the unit information to your dataView? Is this what the dimensions data role represents in your dataViewMapping or is it a custom format string against the measure supplied as the measures data role?
If you're setting a custom format string in the data model (e.g. "0.00 kg"), then it will come into the values array in the dataViewMapping as a raw value and its corresponding columns entry should have a format property that will contain the format string you've set up in the model.
You can then use valueFormatter from powerbi-visuals-utils-formattingutils to format the raw value using the format string from the object metadata. As there's no format property in for the measure metadata in your screenshot I'm guessing that isn't the case though.
Or, are you trying to introduce some logic into your visual to apply a denominator and add units to a measure based on a property?
What would be useful is if we could start with the following information:
If I can get some further detail or clarification hopefully I can provide a more targeted answer for you.
Regards,
Daniel
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Hello @dm-p ,
the dataViewMappings
"dataViewMappings": [
{
"table": {
"rows": {
"select": [
{
"for": {
"in": "dimensions"
}
},
{
"for": {
"in": "measures"
}
}
]
}
}
}
]
and the metadata for the selected measure (Amount here) is like this :
so it is where I have been looking for the unit information, feel free to correct me if i am not in the right place to seek it 🙂
Thanks !
Hi @Anonymous - the dataView contains raw values and then the format for a column or measure, if applied, can be found as a property of its corresponding metadata object.
I'm not sure if this answers your question, so if not, please provide an example of your dataViewMapping and any sample data, plus expected output and I’ll see if I can advise further.
Regards,
Daniel
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
thanks for your reply, @dm-p
take for example this scenario: we have a dataset with measure "weight" whose unit is, say "kg".
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
13 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
25 | |
3 | |
2 | |
2 | |
2 |