Forum Discussion
Trouble with a measure
Ashish_Mathur wrote:Hi,
Try this
=If(HASONEVALUE(Indfortoldning[Løbenummer]),AVERAGE(Indfortoldning[Moms grundlag]),SUMX(SUMMARIZE(Indfortoldning,Indfortoldning[Løbenummer],"ABCD",AVERAGE(Indfortoldning[Moms grundlag])),[ABCD]))
Hope this helps.
Hey there,
Thanks a ton for the above measure, was just what I wanted.
Now I have however stumpled into another issue I hadnt seen coming so I need this measure changed up a bit to work the same way qlikview does. I will do my best to explain the issue but please ask if there is any questions:
So the above measure does the correct, what I hadnt realized was there can be multiple different invoices with the same "løbenummer" and different "Moms grundlag" so if that is the case I want the value to be blank. Lets say we have the below scenario
Invoice 1
Løbenummer 123
Moms grundlag 999
Invoice 2
Løbenummer 123
Moms grundlag 123
The above 2 invoices has same løbenummer but different momsgrundlag, if that is the case I dont want it to take the average or top 1 (both should give same result) I want the value to become blank as if there isnt typed anything into the "moms grundlag" field.
My entire issue is I am doing an SQL query and 1 invoice can have multiple lineitems, so even if "Moms grundlag" is supposed to only have 1 value pr invoice it spits it out as many times as there is lineitems. Qlikview simply take either the average or the top 1 of this value (aint sure how it does it) and in qlikview it can somehow differentiate between two invoices with the same løbenummer, i guess it just makes moms grundlag blank if the same løbenummer exists multiple times but with different moms grundlag.
I hope the above made sense.
Hi,
Share a sample dataset and show the expected result there.
- Shamatix8 years ago
Post Partisan
Ashish_Mathur wrote:Hi,
Share a sample dataset and show the expected result there.
Hey Ashis,
I have uploaded some sample data here and hopefully described it well enough, otherwise feel free to text me back:)
I also do have skype: Snaske2 if that will make the communication easier:)- Ashish_Mathur8 years ago
Super User
Hi,
I am still not clear with your requirement but try this measure
=If(HASONEVALUE(Indfortoldning[Løbenummer]),if(DISTINCTCOUNT(Indfortoldning[Moms grundlag])>1,BLANK(),AVERAGE(Indfortoldning[Moms grundlag])),SUMX(SUMMARIZE(Indfortoldning,Indfortoldning[Løbenummer],"ABCD",if(DISTINCTCOUNT(Indfortoldning[Moms grundlag])>1,BLANK(),AVERAGE(Indfortoldning[Moms grundlag]))),[ABCD]))
Hope this helps.
- Shamatix8 years ago
Post Partisan
Ashish_Mathur wrote:Hi,
I am still not clear with your requirement but try this measure
=If(HASONEVALUE(Indfortoldning[Løbenummer]),if(DISTINCTCOUNT(Indfortoldning[Moms grundlag])>1,BLANK(),AVERAGE(Indfortoldning[Moms grundlag])),SUMX(SUMMARIZE(Indfortoldning,Indfortoldning[Løbenummer],"ABCD",if(DISTINCTCOUNT(Indfortoldning[Moms grundlag])>1,BLANK(),AVERAGE(Indfortoldning[Moms grundlag]))),[ABCD]))
Hope this helps.
https://community.powerbi.com/t5/Desktop/Need-help-with-a-measure/m-p/326065#M145459
I made a new thread, however I am really struggling converting my Qlikview to a 1:1 Power Bi, would love to get you on skype and be able to show you^^